import java.util.Scanner;
public class A4 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("请输入第一个操作数:");
double num1 =input.nextDouble();
System.out.println("请输入第二个操作数:");
if(input.hasNextDouble()) {
double num2 = input.nextDouble();
System.out.println("请选择您需要的功能:1.加法 2.减法 3.乘法 4除法");
int choose = input.nextInt();
switch (choose) {
case 1:
System.out.println("计算结果:"+num1+"+"+num2+"="+(num1+num2));
break;
case 2:
System.out.println("计算结果:"+num1+"-"+num2+" = "+(num1-num2));
break;
case 3:
System.out.println("计算结果:"+num1+"*"+num2+" = "+(num1*num2));
break;
case 4:
System.out.println("计算结果:"+num1+"/"+num2+ " = " +(num1/num2));
break;
default:
break;
}
}else {System.out.println("请输入正确的数字!");
}
}
}
public class A4 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("请输入第一个操作数:");
double num1 =input.nextDouble();
System.out.println("请输入第二个操作数:");
if(input.hasNextDouble()) {
double num2 = input.nextDouble();
System.out.println("请选择您需要的功能:1.加法 2.减法 3.乘法 4除法");
int choose = input.nextInt();
switch (choose) {
case 1:
System.out.println("计算结果:"+num1+"+"+num2+"="+(num1+num2));
break;
case 2:
System.out.println("计算结果:"+num1+"-"+num2+" = "+(num1-num2));
break;
case 3:
System.out.println("计算结果:"+num1+"*"+num2+" = "+(num1*num2));
break;
case 4:
System.out.println("计算结果:"+num1+"/"+num2+ " = " +(num1/num2));
break;
default:
break;
}
}else {System.out.println("请输入正确的数字!");
}
}
}