I have tried for a while to make a simple program, but since I'm new at it, it's taking me a bit to pick up on it. I'm following these instructions
declare and initialize a
char
variable for the student grade;use a for loop that has five iterations;
use the
System.out.println()
method in the for loop to request a grade from the student;use the
System.in.read()
method to receive student grades in the for loop;use the
System.out.println()
method to tell the student to try again if they enter anything other than one letter for a grade;use the
System.out.println()
method after the for loop to output a message for the student; and,compile and run your program.
This is how far I've gotten with no errors when I run it.
package grading.on.a.loop.java;
public class GradingOnALoopJava {
public static void main(String[] args) {
char studentgrade = 100;
System.out.println("Please enter your Grade here.");
for(int counter = 75; counter <= 100; counter += 5) {
System.out.println(counter);
System.out.println("Please enter your Grade.");
}
}
}
this is when I start to run into problems:
package grading.on.a.loop.java;
public class GradingOnALoopJava {
public static void main(String[] args) {
char studentgrade = 100;
System.out.println("Please enter your Grade here.");
for(int counter = 75; counter <= 100; counter += 5) {
System.out.println(counter);
System.out.println("Please enter your Grade.");
System.in.read("");
}
}
}
The "System.in.read
" part is giving me a bit of trouble, no matter what I've done to alter it, it always shows an error.
Any help is appreciated.