简易计算器

package Bo;
import java.util.Scanner;

public class Hello
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while(true){
double x=scanner.nextDouble();
char z=scanner.next().charAt(0);
double y=scanner.nextDouble();
switch (z){
case '+':
System.out.println(add(x,y));
break;
case '-':1
System.out.println(delete(x,y));
break;
case '*':
System.out.println(cheng(x,y));
break;
case '/':
System.out.println(chu(x,y));
break;
}
}
}
public static double add(double a,double b){
return a+b;
}
public static double delete(double a,double b){
return a-b;
}
public static double cheng(double a,double b){
return a*b;
}
public static double chu(double a,double b){
return a/b;
}

}


上一篇:什么是DCL(Double Check Lock)单例?


下一篇:自定义用户类