NOTSOSURE
Dec 7th, 2002, 03:54 PM
i am experamenting with JAVA.
I wanna write a program which will print an ASCII values table using a for loop.
So if i type in a Start Value of "A" and a Last Value of "}" the output should be
ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}
Error conditions
================
If the last character is before the start character print an error message saying:
"Error - last is before start"
Here is the code i have writen so far.. but i cant get the output to show can any one tell me where i am going wrong.
public class Ascii {
public static void main(String[] argv) {
char startChar, lastChar;
String ascii = "";
System.out.println ("Please type the start character");
startChar = UserInput.readChar();
System.out.println ("Please type the last character");
lastChar = UserInput.readChar();
if (lastChar < startChar){
System.out.println ("Error, last character is before start character");
}
for (startChar = startChar; startChar == lastChar; ++startChar){
}
ascii = ascii + startChar;
System.out.println (ascii);
} // end of main
} // end class
thanx ppl
I wanna write a program which will print an ASCII values table using a for loop.
So if i type in a Start Value of "A" and a Last Value of "}" the output should be
ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}
Error conditions
================
If the last character is before the start character print an error message saying:
"Error - last is before start"
Here is the code i have writen so far.. but i cant get the output to show can any one tell me where i am going wrong.
public class Ascii {
public static void main(String[] argv) {
char startChar, lastChar;
String ascii = "";
System.out.println ("Please type the start character");
startChar = UserInput.readChar();
System.out.println ("Please type the last character");
lastChar = UserInput.readChar();
if (lastChar < startChar){
System.out.println ("Error, last character is before start character");
}
for (startChar = startChar; startChar == lastChar; ++startChar){
}
ascii = ascii + startChar;
System.out.println (ascii);
} // end of main
} // end class
thanx ppl