You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
655 B

package guangzhaowei;
import java.util.Scanner;
public class Easy {
public static void c(){
Scanner sc=new Scanner(System.in);
System.out.println("请输入第一个数字:");
double x=sc.nextDouble();
System.out.println("请输入第二个数字");
double y=sc.nextDouble();
System.out.println("请选择相应的数字来进行相应的运算(1:加法 2:减法 3:乘法 4:除法)");
int c=sc.nextInt();
double d=0;
switch(c) {
case 1:d=x+y;System.out.println("运算结果是 "+d);break;
case 2:d=x-y;System.out.println("运算结果是 "+d);break;
case 3:d=x*y;System.out.println("运算结果是 "+d);break;
case 4:d=x/y;System.out.println("运算结果是 "+d);break;
}
}
}