import java.util.Scanner;
class JiSuanQi {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("请输入第一个数据:");
int x = sc.nextInt();
System.out.print("请输入第二个数据:");
int z = sc.nextInt();
System.out.print("请输入计算方法:");
String y = sc.next();
switch (y) {
case "+" :
System.out.println("x + z ="+(x+z));
break;
case "-" :
System.out.println("x - z ="+(x - z));
break;
case "/" :
System.out.println("x / z ="+(x / z));
break;
case "*" :
System.out.println("x * z ="+(x*z));
break;
default :
System.out.println("这不是一个算法");
}
}
}
因为只学了前几天的代码,所以这个计算器的局限很多,仅限于Int类型的计算
|
|