|
-
Dec 23rd, 2002, 04:55 PM
#1
Thread Starter
Lively Member
Can't Input Last Character; Program Ends Abruptly
import java.io.*;
public class Ascii {
public static void main(String[] args) {
TextReader UserInput = new TextReader(System.in);
System.out.println ("Please type the start character");
char startChar = UserInput.readChar();
System.out.println ("Please type the last character");
char lastChar = UserInput.readChar();
if (lastChar < startChar){
System.out.println ("Error, last character is before start character");
}
for (char ascii = startChar; ascii <= lastChar; ++ascii){
System.out.print (ascii);
}
} // end of main
} // end class
The output of the above code gives me the following:
Please type the start character
a
Please type the last character
Error, last character is before start character
Press any key to continue...
The program doesn't give me time to input the last character. Any suggestions?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|