Ok im writing a program in java thats suppose to Use a while loop, to print the lower case alphabeth and its corresponding ascii values
of the upper case alphabeth from Z to A

So far i came up with

while

(counter +32) (char) (counter +32)

if (counter < ?)
break;

now i just need a little bit of help with putting it in the right format thats if im even in the right direction

Recommended Answers

All 6 Replies

Start the value of counter with the equivalent ascii value of a
at the loop
print out the char and int value of counter and
then use the equivalent value of z as the loop condition

Start the value of counter with the equivalent ascii value of a
at the loop
print out the char and int value of counter and
then use the equivalent value of z as the loop condition

so how would that look in code? i'm just starting to learn how to use java so i can use the help

pseudo:

int counter=97; //ascii value of a or start with the value of desired letter
int counter2; // the varible for the uppercase value
start loop
while counter is less than 123 //condition so that z is the last letter printed or use another condition depending on the last letter
assign value of counter2 to be counter minus 32 //ascii value of uppercase letters
print (char) counter and counter2
add 1 to counter // or decrement depending if it's z to a or a to z
end loop

pseudo:

int counter=97; //ascii value of a or start with the value of desired letter
int counter2; // the varible for the uppercase value
start loop
while counter is less than 123 //condition so that z is the last letter printed or use another condition depending on the last letter
assign value of counter2 to be counter minus 32
print (char) counter and counter2
add 1 to counter // or decrement depending if it's z to a or a to z
end loop

oh ok i get it now thanks so much for your help

oh ok i get it now thanks so much for your help

ok this is what i got am i on the right track????

int counter = 97;
        int counter2;

        while ( counter < 123)
        {
            counter2 = counter - 32;
            System.out.print((char) counter + counter2);
            counter++;

            if (counter > 123)
                break;

        }
if (counter > 123)
break;

this is redundunt there's already condition for this in the while loop

to print the lower case alphabeth and its corresponding ascii values
of the upper case alphabeth from Z to A

the example I stated prints it from a to z with it's corresponding upper-case ASCII values, if you need it differently you could manipulate the counter, starting value and loop condition to your liking

if you still have any problems afterwards then could you post your desired output

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.