public class Demo1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入数字");
int first = sc.nextInt();
double total = first;
while (true) {
System.out.println("请输入运算符和数字");
String next = sc.next();
if(next.equals("exit")){
break;
}else{
String head = next.substring(0, 1);
String tail = next.substring(1);
double tail_now = Double.parseDouble(tail);
if (head.equals("*")) {
total = total * tail_now;
} else if (head.equals("/")) {
total = total / tail_now;
} else if (head.equals("+")) {
total = total + tail_now;
} else if (head.equals("-")) {
total = total - tail_now;
}
System.out.println("当前运算结果:"+total);
}
}
System.out.println("最终结果为:"+total);
}
}