How can i repeat statement "enter marks or grade" with in while loop.In this case every time control back to start of loop. and i want to repeat enter marks until user want to leave?
public class Marks2 {
public static void main(String args[]){
Scanner s=new Scanner(System.in);
System.out.println("Here is Subject list");
System.out.println("1-Physics");
System.out.println("2-Math");
System.out.println("3-computer");
boolean input=true;
while (input){
System.out.println("Enter subject number here");
String sub=s.nextLine();
if(sub.equals("1")) {
System.out.println("Physics");
System.out.println("");
System.out.println("Enter marks /Enter change for change /Enter exit for leave");
String change1 = null;
String change2 = null;
int marks = 0;
try {
change1 = s.nextLine();
marks = Integer.parseInt(change1);
} catch (Exception e) {
System.out.println("Please enter only string value");
change2 = s.nextLine();
if (change2.equals("change")) {
continue;
} else if (change2.equals("exit")) {
System.exit(0);
}
}
if(marks<40){
System.out.println("Student is fail");
}
else if(marks==40){
System.out.println("Student is fail he need more practice");
}
else if(marks<70){
System.out.println("need more practice but also good");
}
else if(marks==70){
System.out.println("Good");
}
else if(marks<90){
System.out.println("Good but also Excellent");
}
else if(marks==90){
System.out.println("Excellent");
}
else if(marks<100){
System.out.println("Outstanding");
}
else if(marks==100){
System.out.println("Good but also excellent");
}
else if(change1.equals("change")){
continue;
}
else if(change2.equals("exit")){
System.exit(0);
}
else {
System.out.println("");
}
continue;
}
}
}
}
After continue control went to start of loop and ask to enter subject again. Is it possible to enter grade until user wants to leave?