import java.util.Scanner;
public class day5_04 {
public static void main(String[]args){
System.out.println("*计算器\n加法<1>\t减法<2>\t乘法<3>\t除法<4>\n:");
Scanner a=new Scanner(System.in);
byte jiance=0;
byte jiance2=0;
byte jiance3=0;
byte jiance4=0;
byte jiance5=0;
int jiashu1=0;
int jiashu2=0;
while(jiance==0&&jiance2==0){
boolean yi2=a.hasNextInt();
jiance2=1;
if(yi2==(false)){
System.out.println("*请选择\n加法<1>\t减法<2>\t乘法<3>\t除法<4>\n:");
String nazou=a.next();
jiance2=0;
}
boolean yi1=a.hasNextInt();
if(yi1&&jiance2==1){
int js=a.nextInt();
if(yi1&&js<=4&&js>=1){
switch(js){
case 1:
jiance5=0;
jiance3=0;
jiance4=0;
while(jiance3==0&&jiance4==0&&jiance5==0){
System.out.println("*加法\t第一个数:");
Scanner jiaa=new Scanner(System.in);
while(jiance3==0&&jiance4==0){
boolean er1=jiaa.hasNextInt();
jiance4=1;
if(er1==(false)){
System.out.println("*加法\t输入错误--重新输入");
String nazou2=jiaa.next();
jiance4=0;
}
boolean er2=jiaa.hasNextInt();
if(er2&&jiance4==1){
jiashu1=jiaa.nextInt();
jiance4=1;
}
}
Scanner jiab=new Scanner(System.in);
while(jiance3==0&&jiance4==1){
System.out.println("*加法\t第二个数:");
boolean er1=jiab.hasNextInt();
jiance3=1;
if(er1==(false)){
System.out.println("*加法\t输入错误--重新输入");
String nazou3=jiab.next();
jiance3=0;
}
boolean er2=jiab.hasNextInt();
if(er2&&jiance3==1){
jiashu2=jiab.nextInt();
int jisuan=jiashu1+jiashu2;
System.out.println("计算:\n"+jiashu1+"+"+jiashu2+"="+jisuan);
jiance=0;
jiance2=0;
jiance3=0;
jiance4=0;
jiance5=1;
System.out.println("*重新选择\n加法<1>\t减法<2>\t乘法<3>\t除法<4>\n:");
}
}
}
break;
case 2:
jiance3=0;
jiance4=0;
jiance5=0;
while(jiance3==0&&jiance4==0&&jiance5==0){
System.out.println("*减法\t第一个数:");
Scanner jiaa=new Scanner(System.in);
while(jiance3==0&&jiance4==0){
boolean er1=jiaa.hasNextInt();
jiance4=1;
if(er1==(false)){
System.out.println("*减法\t输入错误--重新输入");
String nazou2=jiaa.next();
jiance4=0;
}
boolean er2=jiaa.hasNextInt();
if(er2&&jiance4==1){
jiashu1=jiaa.nextInt();
jiance4=1;
}
}
Scanner jiab=new Scanner(System.in);
while(jiance3==0&&jiance4==1){
System.out.println("*减法\t第二个数:");
boolean er1=jiab.hasNextInt();
jiance3=1;
if(er1==(false)){
System.out.println("*减法\t输入错误--重新输入");
String nazou3=jiab.next();
jiance3=0;
}
boolean er2=jiab.hasNextInt();
if(er2&&jiance3==1){
jiashu2=jiab.nextInt();
int jisuan=jiashu1-jiashu2;
System.out.println("计算:\n"+jiashu1+"-"+jiashu2+"="+jisuan);
jiance=0;
jiance2=0;
jiance3=0;
jiance4=0;
jiance5=1;
System.out.println("*重新选择\n加法<1>\t减法<2>\t乘法<3>\t除法<4>\n:");
}
}
}
break;
case 3:
jiance3=0;
jiance4=0;
jiance5=0;
while(jiance3==0&&jiance4==0&&jiance5==0){
System.out.println("*乘法\t第一个数:");
Scanner jiaa=new Scanner(System.in);
while(jiance3==0&&jiance4==0){
boolean er1=jiaa.hasNextInt();
jiance4=1;
if(er1==(false)){
System.out.println("*乘法\t输入错误--重新输入");
String nazou2=jiaa.next();
jiance4=0;
}
boolean er2=jiaa.hasNextInt();
if(er2&&jiance4==1){
jiashu1=jiaa.nextInt();
jiance4=1;
}
}
Scanner jiab=new Scanner(System.in);
while(jiance3==0&&jiance4==1){
System.out.println("*乘法\t第二个数:");
boolean er1=jiab.hasNextInt();
jiance3=1;
if(er1==(false)){
System.out.println("*乘法\t输入错误--重新输入");
String nazou3=jiab.next();
jiance3=0;
}
boolean er2=jiab.hasNextInt();
if(er2&&jiance3==1){
jiashu2=jiab.nextInt();
int jisuan=jiashu1*jiashu2;
System.out.println("计算:\n"+jiashu1+"*"+jiashu2+"="+jisuan);
jiance=0;
jiance2=0;
jiance3=0;
jiance4=0;
jiance5=1;
System.out.println("*重新选择\n加法<1>\t减法<2>\t乘法<3>\t除法<4>\n:");
}
}
}
break;
case 4:
jiance3=0;
jiance4=0;
jiance5=0;
while(jiance3==0&&jiance4==0&&jiance5==0){
System.out.println("*除法\t第一个数:");
Scanner jiaa=new Scanner(System.in);
while(jiance3==0&&jiance4==0){
boolean er1=jiaa.hasNextInt();
jiance4=1;
if(er1==(false)){
System.out.println("*除法\t输入错误--重新输入");
String nazou2=jiaa.next();
jiance4=0;
}
boolean er2=jiaa.hasNextInt();
if(er2&&jiance4==1){
jiashu1=jiaa.nextInt();
jiance4=1;
}
}
Scanner jiab=new Scanner(System.in);
while(jiance3==0&&jiance4==1){
System.out.println("*除法\t第二个数:");
boolean er1=jiab.hasNextInt();
jiance3=1;
if(er1==(false)){
System.out.println("*除法\t输入错误--重新输入");
String nazou3=jiab.next();
jiance3=0;
}
boolean er2=jiab.hasNextInt();
if(er2&&jiance3==1){
jiashu2=jiab.nextInt();
int jisuan=jiashu1/jiashu2;
System.out.println("计算:\n"+jiashu1+"/"+jiashu2+"="+jisuan);
jiance=0;
jiance2=0;
jiance3=0;
jiance4=0;
jiance5=1;
System.out.println("*重新选择\n加法<1>\t减法<2>\t乘法<3>\t除法<4>\n:");
}
}
}
break;
default:
System.out.println("**请选择\n加法<1>\t减法<2>\t乘法<3>\t除法<4>\n:");
jiance=0;
jiance2=0;
break;
}
}else{
System.out.println("**请选择\n加法<1>\t减法<2>\t乘法<3>\t除法<4>\n:");
jiance=0;
jiance2=0;
}
}
}
}
}