该程序运行良好,但我想让该程序告诉用户不应使用字母,只有选项 1 到 5。有人可以帮我弄清楚吗?
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");
}