Basically, what I want my code to do is if the user inputs anything besides "sum, quit, max, min" I want the program to loop back and ask the user the options again. I tried using a while-loop but I can't add multiple String objects within it. I'm stuck on what to do. (Also, I used if-statements instead of while so it won't continually repeat and be stuck.)
public static void main (String [] args){
System.out.println("Enter the option sum, max, min:");
Scanner input = new Scanner (System.in);
user = input.nextLine();
double [] y = theArray();
if (user.equals("sum")){
//do something
}
else if (user.equals("max")){
//do something
}
else if (user.equals("min")){
//do something
}
else if (user.equals("Quit")){
//do something
}
}
}
Aucun commentaire:
Enregistrer un commentaire