package mygradeloops;
import java.io.IOException;
public class MyGradeLoops {
public static void main(String[] args) throws IOException {
char x = \'A\';
It's "double printing" because when you enter a character by pressing return, you're actually writing two characters: the character you typed, and \n
(newline character).
Add a second System.in.read();
call to read the newline character:
for (x='0';x<'9';x++){
System.out.println("Please enter in one of your grades.");
System.in.read(); // your character
System.in.read(); // newline
System.out.println("Keep going!");
}
Also, initializing x
to 'A'
in not needed, char x;
is fine. In fact, it doesn't make sense to use a char
in this loop, using an int
would be preferred.