0

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

2
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by zeroliken
0

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

Edited by zeroliken: n/a

0

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

0

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

Edited by zeroliken: n/a

0

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

0

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;

        }

Edited by Dani: Formatting fixed

0
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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.