主菜單:
1.Plus
2.Minus
3.Multiply
4.Division
5.Exit
選項:我必須在此後添加什麼之後添加什麼? System.out.println(「*按任意鍵回到菜單*」);
如果菜單1:
瓦爾答:... 5 < - 用戶條目
變量B:... 3 < - 用戶條目
結果:8
5> 3
按任意鍵回到菜單
我必須在此之後添加什麼?
System.out.println(「按任意鍵回到菜單」);
我很困惑,請任何人親可以幫我(T-T),非常感謝你!
import java.util.Scanner;
class case2 {
public static void main(String args[]) {
Scanner entry = new Scanner(System.in);
int a, b;
int i;
do {
System.out.println("Main Menu :");
System.out.println("1. Plus");
System.out.println("2. Minus");
System.out.println("3. Multiply");
System.out.println("4. Division");
System.out.println("5. Exit");
System.out.println("Option :");
i = entry.nextInt();
System.out.println(" ");
switch(i) {
case 1 :
System.out.println("Menu 1 :");
System.out.print("Var A :");
a = entry.nextInt();
System.out.print("Var B :");
b = entry.nextInt();
System.out.println("Result :" + (a+b));
if(a>b) {
System.out.println(a +" > "+b);
}
else if(a<b) {
System.out.println(a +" < "+b);
}
else {
System.out.println(a +" = "+b);
}
System.out.println("*press any key back to menu*");
break;
case 2 :
System.out.println("Menu 2 :");
System.out.print("Var A :");
a = entry.nextInt();
System.out.print("Var B :");
b = entry.nextInt();
System.out.println("Result :" + (a-b));
if(a>b) {
System.out.println(a +" > "+b);
}
else if(a<b) {
System.out.println(a +" < "+b);
}
else {
System.out.println(a +" = "+b);
}
System.out.println("*press any key back to menu*");
break;
case 3 :
System.out.println("Menu 3 :");
System.out.print("Var A :");
a = entry.nextInt();
System.out.print("Var B :");
b = entry.nextInt();
System.out.println("Result :" + (a*b));
if(a>b) {
System.out.println(a +" > "+b);
}
else if(a<b) {
System.out.println(a +" < "+b);
}
else {
System.out.println(a +" = "+b);
}
System.out.println("*press any key back to menu*");
break;
case 4 :
System.out.println("Menu 4 :");
System.out.print("Var A :");
a = entry.nextInt();
System.out.print("Var B :");
b = entry.nextInt();
System.out.println("Result :" + (a/b));
if(a>b) {
System.out.println(a +" > "+b);
}
else if(a<b) {
System.out.println(a +" < "+b);
}
else {
System.out.println(a +" = "+b);
}
System.out.println("*press any key back to menu*");
break;
case 5:
break;
default:
System.out.println("ERROR");
System.out.println("*press any key back to menu*");
}
}while(i != 5);
}
}
需要點擊任意鍵i型... – BeginnerToJava
如何使它自動返回菜單無需使用鑰匙進入後我型 - 任意鍵後,進入後??? – BeginnerToJava
我認爲你不能沒有本地代碼和JNI。看看Java Curses庫:http://sourceforge.net/projects/javacurses/ – pinokio