This program works well but I want to make this program tell the user that no letters should be used there are only options 1 to 5. Can someone please help me in figuring that out?
public class Main {
Scanner input = new Scanner ( System.in );
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int UserIn=0;
double numberInputA;
double numberInputB;
double Answer;
Scanner input = new Scanner( System.in );
while (UserIn!=5){ //this starts while loop when user input is not equal to 5
System.out.println ("What type of calculation would you like to perform?");
System.out.println ( "1. Add\n2. Subtract\n" +
"3. Multiply\n4. Divide\n5. Exit");//shows the menu
UserIn = input.nextInt();//ask user to input integer of choice
if (UserIn>5){
System.out.println( "ERROR choose the numbers on the menu" );
}else if (UserIn<1){
System.out.println("ERROR choose the numbers on the menu");
}
1 Answer