Calculator
import java.util.Scanner;
public class Sum_
{
public static void main(String args[])
{
int x,y;
char k;
String str ;
Scanner reader= new Scanner(System.in);
while((str=reader.nextLine())!=null)
{
k=str.charAt(1);
x=Integer.parseInt(String.valueOf(str.charAt(0)));
y=Integer.parseInt(String.valueOf(str.charAt(2)));
switch(k)
{
case '+':
System.out.printf("%d\n",x+y);
break;
case '-':
System.out.printf("%d\n",x-y);
break;
case '*':
System.out.printf("%d\n",x*y);
break;
case '/':
System.out.printf("%d\n",(double)x/(double)y);
break;
default :
System.out.printf("输入错误\n");
break;
}
str="";
//System.out.printf("%d",);
}
}
}
posted on 2017-10-21 10:26 MACHINE_001 阅读(118) 评论(0) 编辑 收藏 举报