import java.io.*; import java.util.*; public class Test { public static void main(String[] args) throws IOException { double x,y,z=0; char ch; Scanner rd=new Scanner(System.in); BufferedReader buf =new BufferedReader(new InputStreamReader(System.in)); System.out.println("请输入X,Y:"); x=rd.nextDouble(); y=rd.nextDouble(); System.out.println("请输入运算符:"); ch=(char)buf.read(); switch(ch) { case'+':z=x+y;break; case'-':z=x-y;break; case'*':z=x*y;break; case'/':z=x/y;break; default:System.out.println("输入的运算符不正确哦!"); } System.out.println("运算结果是:"+z); } }