import
import
import
import java.util.StringTokenizer;
public class Calculator
{
public static void main(String[]arguments) throws IOException
{
InputStreamReader input=new InputStreamReader(System.in);
BufferedReader reader=new BufferedReader(input);
String line;
double d1,d2,sum=0;
int n=1;
while(n==1){
System.out.println("请输入要计算的两个数,和运算符:");
line =reader.readLine();
StringTokenizer strtokenizer=new StringTokenizer(line,"+-*/",true);
d1=Double.parseDouble(strtokenizer.nextToken());
String str=strtokenizer.nextToken();
d2=Double.parseDouble(strtokenizer.nextToken());
switch(str)
{
case "+":sum=d1+d2;break;
case "-":sum=d1-d2;break;
case "*":sum=d1*d2;break;
case "/":sum=d1/d2;break;
default :System.out.println("没有对应的运算符!");break;
}
System.out.println(sum+"\n");
System.out.println("是否继续运算?是:请输入1;否:请输入0");
String str1=reader.readLine();
StringTokenizer strtokenizer1=new StringTokenizer(str1,"+");
n=Integer.parseInt(strtokenizer1.nextToken());
}
System.out.println("谢谢使用!");
}
}
试试看满不满足要求