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.
p6hsylpbf/c.java

27 lines
591 B

import java.util.Scanner;
public class CALC{
public static void main(String args[]){
double x;
double y;
String z;
Scanner sc=new Scanner(System.in)
System.out.println("输入第一个数:");
x=sc.nextDouble();
System.out.println("输入运算符:");
z=sc.next();
System.out.println("输入第二个数:");
y=sc.nextDouble();
System.out.print("结果是:");
switch(z){
case"+":System.out.println(x+y);
break;
case"-":System.out.println(x-y);
break;
case"*":System.out.println(x*y);
break;
case"/":System.out.println(x/y);
break;
}
}
}