package SiZeiYunSuan;
import java.util.Scanner;
public class Jiajianchengchu_6 {
public static void main(String[] args) { double a; double b;
Scanner sc = new Scanner(System.in); String choice = \; boolean flag = true;
while (flag) {
System.out.println(\请输入第一个数:\); try {
a = sc.nextDouble();
sc.nextLine();
System.out.println(\请输入操作符( + or - or * 0r / )\); sc = new Scanner(System.in); choice = sc.nextLine(); boolean flag1 = true; while (flag1) {
System.out.println(\请输入第二个数\); try {
b = sc.nextDouble(); sc.nextLine();
if (choice.equals(\) && b == 0) {
System.out.println(\除数不能为0,请重新输入!\); b = sc.nextDouble(); flag1 = true; }
if (choice.equals(\)) {
System.out.println(a + \ + b + \ + (a + }
if (choice.equals(\)) {
System.out.println(a + \ + b + \ + (a - }
if (choice.equals(\)) {
System.out.println(a + \ + b + \ + (a *
b)); b)); b));
}
if (choice.equals(\)) { if (b == 0) { flag1 = true; / b)); n)\);
\);
}
}
}
} else {
System.out.println(a + \ + b + \ + (a } }
System.out.println(\你是否要继续? (y or flag = false; flag1 = false;
sc = new Scanner(System.in); choice = sc.nextLine(); if (choice.equals(\)) { flag = true; } else {
flag = false; flag1 = false;
System.out.println(\谢谢使用!\);
}
} catch (Exception e) { sc.nextLine();
System.out.println(\您输入的不是数字,请重新输入1!
flag1 = true;
}
}
} catch (Exception e) { sc.nextLine();
System.out.println(\您输入的不是数字,请重新输入2!\); flag = true; }
相关推荐: