package com.k9999.method;
import java.util.Scanner;
public class Demo06 {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
System.out.print(“请输入第一个数字”);
double a=scanner.nextDouble();
System.out.print(“请输入加减乘除任意一个”);
String symbol=scanner.next();
System.out.print(“请输入第二个数字”);
double b=scanner.nextDouble();
switch (symbol)
{
case “+”:
System.out.println(add(a,b));
break;
case “-”:
System.out.println(sub(a,b));
break;
case “*”:
System.out.println(multPul(a,b));
break;
case “/”:
System.out.println(div(a,b));
break;
}
scanner.close();
}
public static double add(double a,double b){
return a+b;
}
public static double sub(double a,double b){
return a-b;
}
public static double multPul(double a,double b){
return a*b;
}
public static double div(double a,double b){
return a/b;
}