Im trying to make the program to ask for a percentage (grade) but I want it to ask again after the user has made the first input and has seen the output. I'm having trouble with the loop because the variable myMark is no assigned.
import java.util.Scanner;
public class passFail{
public static void main(String[] args){
Scanner result = new Scanner(System.in);
int myMark = 0;
while(myMark >=0 && myMark <=100){
System.out.println("Please enter the percentage you have received:");
myMark = result.nextInt();
if(myMark <=49 && myMark >=0){
System.out.println("You have failed!");
}
else if(myMark <=59 && myMark >=50){
System.out.println("You have passed!");
}
else if(myMark <=69 && myMark >=60){
System.out.println("You have received a Credit");
}
else if(myMark <=79 && myMark >=70){
System.out.println("You have received a Distinction!");
}
else if(myMark <=100 && myMark >=80){
System.out.println("You have received a High Distinction");
}
else{
System.out.println("Please enter a whole number");
}
}
}
}