import java.util.Scanner;
class NumberActors
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("请输入第一个数据:");
int number1 = sc.nextInt();
System.out.println("请输入运算符号:");
String Operations = sc.next();
System.out.println("请输入第二个数据:");
int number2 = sc.nextInt();
switch(Operations)
{
case "+":
{
int sum = number1 + number2;
System.out.println("sum = "+ number1 + "+" + number2 + "=" + (number1+number2));
break;
}
case "-":
{
int sum = number1 + number2;
System.out.println("sum = "+ number1 + "-" + number2 + "=" + (number1-number2));
break;
}
case "*":
{
int sum = number1 + number2;
System.out.println("sum = "+ number1 + "*" + number2 + "=" + (number1*number2));
break;
}
case "/":
{
int sum = number1 + number2;
System.out.println("sum = "+ number1 + "/" + number2 + "=" + (number1/number2));
break;
}
}
}
}
|
|