import java.util.Scanner;
public class Demo {
public static void main(String[] args) {
System.out.println("将开始10次加法测试。。。");
Scanner scanner = new Scanner(System.in);
int score = 0;
for (int i=0;i<=10;i++){
int a = (int)(Math.random()*100+1);
int b = (int)(Math.random()*100+1);
int c=a+b;
System.out.println("("+ i+")"+"."+a+"+"+b+"="+"?");
System.out.println("请输入答案(输入-1退出)");
int aw = scanner.nextInt();
if (aw==-1){
break;
}else if (aw==c){
System.out.println("正确");
score+=10;
}else
System.out.println("错误");
}
scanner.close();
System.out.println("您的成绩是:"+score);
}
}
java随机加法游戏
最新推荐文章于 2021-11-18 18:51:25 发布