public class jisuanqi {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.println("输入一个数");
double a = s.nextDouble();// 从键盘上输入一个数
System.out.println("输入要做的运算符");
String str = s.next();// 从键盘上输入一次字符
System.out.println(str);
System.out.println("输入另一个数");
double c = s.nextDouble();// 从键盘上接受另一个数
//==比较的是字符串在内存中的地址值,比较字符串的内容要用equalsIgnoreCase if ("+".equalsIgnoreCase(str)) {// 拿输入的字符与之判断
add(a, c);// 如果成立调用方法
} else if ("-".equalsIgnoreCase(str)) {
jian(a, c);
} else if ("*".equalsIgnoreCase(str)) {
cheng(a, c);
} else if ("/".equalsIgnoreCase(str)) {
chu(a, c);
}
//System.out.println("输入有误");
}
public static double add(double a, double c) {
double sum;
sum = a + c;
System.out.println(sum);
return sum;
}
public static double jian(double a, double c) {
double sum;
sum = a - c;
System.out.println(sum);
return sum;
}
public static double cheng(double a, double c) {
double sum;
sum = a * c;
System.out.println(sum);
return sum;
}
public static double chu(double a, double c) {
double sum;
sum = a / c;
System.out.println(sum);
return sum;
}
}