简单的加减乘除(递归)
package method;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
//简易的计算器
Scanner scanner = new Scanner(System.in);
System.out.println("请输入第一个值:");
double x = scanner.nextDouble();
System.out.println("请输入第二个值:");
double y = scanner.nextDouble();
System.out.println("请输入符号:");
String operator = scanner.next();
switch (operator){
case "+":
add(x, y);
System.out.println(x+y);
break;
case "-":
sub(x, y);
System.out.println(x-y);
break;
case "*":
mul(x, y);
System.out.println(x*y);
break;
case "/":
div(x, y);
System.out.println(x/y);
break;
}
}
public static double add(double x,double y){
return x+y;
}
public static double sub(double x,double y){
return x-y;
}
public static double mul(double x,double y){
return x*y;
}
public static double div(double x,double y){
return x/y;
}
}
标签:递归,double,System,static,简单,println,out,public,加减乘除
From: https://www.cnblogs.com/kunlexiangshuijiao/p/18202751