ckage test001;import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;public class ComputTest {
public static void main(String args[])throws IOException{
BufferedReader buf;
String s;
int x=12,y=5;
int a ;
buf=new BufferedReader(new InputStreamReader(System.in));
System.out.print("输入一个符号:");
s=buf.readLine();
char ch=s.charAt(0);
switch(ch){
case'+':
a=x+y;
System.out.println(a);
break;
case'-':
a=x-y;
System.out.println(a);
break;
case'*':
a=x*y;
System.out.println("a");
break;
case'/':
a=x/y;
System.out.println("a");
break;
default:
System.out.println("输入有误!");
}
}
}
|
|