package com.tang.method;
import java.util.Scanner;
public class Demo06 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入计算规则:");
String op =scanner.nextLine();
System.out.println("请输入第一个数:");
double a =scanner.nextDouble();
//String x =scanner.nextLine();
System.out.println("请输入第二个数:");
double b =scanner.nextDouble();
//String y =scanner.nextLine();
switch (op){
case "+":
System.out.println("a+b= "+(a+b));
break;
case "-":
System.out.println("a-b= "+(a-b));
break;
case "*":
System.out.println("a*b= "+(a*b));
break;
case "/":
System.out.println("a/b= "+(a/b));
break;
default:
System.out.println("输入无效");
scanner.close();
}
}
}
原创文章,作者:carmelaweatherly,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/271284.html