import java.util.*;
import java.io.*;
class suijishu
{
public static int oneadd (){
int a;
a=(int)(Math.random()*10);
return a;
}
public static int twoadd (){
int a;
a=(int)(Math.random()*100);
return a;
}
public static int threeadd (){
int a;
a=(int)(Math.random()*1000);
return a;
}
public static void exit(){
return;
}
}
public class shuijishuadd extends suijishu
{
public static void main (String[] args) throws IOException
{
int a=0;
int b=0;
int choiceadd;
int i=4;
System.out.println("选择难度");
System.out.println("一位数运算————————————————1");
System.out.println("二位数运算————————————————2");
System.out.println("三位数运算————————————————3");
System.out.println("退出——————————————————————0");
Scanner scan = new Scanner(System.in);
choiceadd=scan.nextInt();
if (choiceadd==1)
{
a=oneadd();
b=oneadd();
System.out.println("两个操作数:"+a+","+b);
}
else if (choiceadd==2)
{ a=twoadd();
b=twoadd();
System.out.println("两个操作数:"+a+","+b);
}
else if(choiceadd==3)
{ a=threeadd();
b=threeadd();
System.out.println("两个操作数:"+a+","+b);
}
else if(choiceadd==0)
{
System.exit(0);
}
int choicead=0;
int k=0;
while(true)
{
int c;
System.out.println("加法————————————————4");
System.out.println("减法————————————————5");
System.out.println("乘法————————————————6");
System.out.println("除法————————————————7");
System.out.println("退出————————————————8");
Scanner pano1 = new Scanner(System.in);
choiceadd=pano1.nextInt();
if (choiceadd==4)
{
System.out.print("请输入结果:");
Scanner pano2 = new Scanner(System.in);
choicead=pano2.nextInt();
c=a+b;
System.out.println("正确结果"+c);
if (c==choicead)
{
System.out.println("你果然是个传说,你答对了");
k=k+1;
}
else
{
System.out.println("你太2了");
}
}
if (choiceadd==5)
{
System.out.print("请输入结果:");
Scanner pano3 = new Scanner(System.in);
choiceadd=pano3.nextInt();
c=a-b;
System.out.println("正确结果"+c);
if (c==choicead)
{
System.out.println("你果然是个传说,你答对了");
k=k+1;
}
else
{
System.out.println("你太2了");
}
}
if (choiceadd==6)
{
System.out.print("请输入结果:");
Scanner pano4 = new Scanner(System.in);
choicead=pano4.nextInt();
c=a*b;
System.out.println("正确结果"+c);
if (c==choicead)
{
System.out.println("你果然是个传说,你答对了");
k=k+1;
}
else
{
System.out.println("你太2了");
}
}
if (choiceadd==7)
{
System.out.print("请输入结果:");
Scanner pano5 = new Scanner(System.in);
choicead=pano5.nextInt();
c=a/b;
System.out.println("正确结果"+c);
if (c==choicead)
{
System.out.println("你果然是个传说,你答对了");
k=k+1;
}
else
{
System.out.println("你太2了");
}
}
if (choiceadd==8)
{
System.exit(0);
}
System.out.print("你的总得分"+k);
System.out.println(" 继续做题如果不做请选8");
}
}
}
求帮助加注 io异常 和 算术异常 被0整除 这俩个异常谢谢