郑州轻工业大学OJ:java1037

import java.util.Scanner;

public class Main{
public static void main(String[] args) {
double a;
double b;
String c;
double d;
Scanner in=new Scanner(System.in);
a=in.nextDouble();
c=in.next();
b=in.nextDouble();
switch© {
case “+”:
d=a+b;
System.out.println(String.format("%.2f", d));
break;
case “-”:
d=a-b;
System.out.println(String.format("%.2f", d));
break;
case “":
d=a
b;
System.out.println(String.format(”%.2f", d));
break;
case “/”:
if(Math.abs(b)<1e-10) {
System.out.println(“Wrong input!”);
break;
}else {
d=a/b;
System.out.println(String.format("%.2f", d));
break;
}
default:
System.out.println(“Wrong input!”);
break;
}
}
}

你可能感兴趣的:(郑州轻工业大学OJ:java1037)