//小学生口算题卡系统(不能为负数和小数,小小学生还不知道)
import java.util.Scanner;
public class SwitchFor {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
int m1 = 1234;
int pass;
int sum1 = 0,sum2 = 0;//总题数,对题数
//int i;
int x,y,i = 1;
int z,j,choice;
int num;
System.out.println("<<欢迎使用天命学习软件>>");
System.out.println("密码只能输入三次");
while(i <= 3)
{
System.out.println("请输入密码:");
pass = input.nextInt();
if(pass == m1)
{
System.out.println("恭喜你,登陆成功");
while(true)
{
System.out.println("1,加法运算");
System.out.println("2,减法运算");
System.out.println("3,乘法运算");
System.out.println("4,除法运算");
System.out.println("5,退出系统");
System.out.print("请输入你的选择");
choice = input.nextInt();
switch(choice)
{
case 1:
System.out.print("请输入你要完成的题目数:");
num = input.nextInt();
for(i = 1;i <= num;i ++)
{
x = (int)(Math.random() * 10);
y = (int)(Math.random() * 10);
System.out.print(x + "+" + y + "=");
z = input.nextInt();
if(z == (x + y))
{
System.out.println("恭喜你,回答正确");
sum2 ++;
}
else
{
System.out.println("答案错误,正确答案为:" + x + "+" + y + "=" + (x + y));
}
sum1 ++;
}
break;
case 2:
System.out.print("请输入你要完成的题目数:");
num = input.nextInt();
for(i = 1;i <= num;)
{
x = (int)(Math.random() * 10);
y = (int)(Math.random() * 10);
if(x > y)
{
System.out.print(x + "-" + y + "=");
z = input.nextInt();
if(z == (x - y))
{
System.out.println("恭喜你,回答正确");
sum2 ++;
}
else
{
System.out.println("答案错误,正确答案为:" + x + "-" + y + "=" + (x + y));
}
sum1 ++;
i ++;
}
}
break;
case 3:
System.out.print("请输入你要完成的题目数:");
num = input.nextInt();
for(i = 1;i <= num;i ++)
{
x = (int)(Math.random() * 10);
y = (int)(Math.random() * 10);
System.out.print(x + "*" + y + "=");
z = input.nextInt();
if(z == (x * y))
{
System.out.println("恭喜你,回答正确");
sum2 ++;
}
else
{
System.out.println("答案错误,正确答案为:" + x + "*3" + y + "=" + (x + y));
}
sum1 ++;
}
break;
case 4:
System.out.println("友情提示:只写整数部分,不用考虑四舍五入");
System.out.print("请输入你要完成的题目数:");
num = input.nextInt();
for(i = 1;i <= num;)
{
x = (int)(Math.random() * 10);
y = (int)(Math.random() * 10);
if(x > y && y != 0)
{
System.out.print(x + "/" + y + "=");
z = input.nextInt();
if(z == (x / y))
{
System.out.println("恭喜你,回答正确");
sum2 ++;
}
else
{
System.out.println("答案错误,正确答案为:" + x + "/" + y + "=" + (x + y));
}
i ++;
sum1 ++;
}
}
break;
case 5:
System.out.println("总题数:" + sum1 + "答对的题数:" + sum2);
System.out.println("系统已退出,欢迎下次使用");
System.exit(0);
break;
default:
System.out.println("选择错误。请重新选择");
}
}
}
else
{
System.out.println("密码输入错误");
}
i ++;
}
System.out.println("密码错误三次。请明天再来");
}
}
版权声明:
本文来源网络,所有图片文章版权属于原作者,如有侵权,联系删除。
本文网址:https://www.bianchenghao6.com/java-jiao-cheng/10971.html