随机加法运算计算器

Scanner scan =new Scanner(System.in);

	int score = 0;
	for (int i=1;i<=10;i++){
		
		int a = (int)(Math.random()*100);
		int b = (int)(Math.random()*100);
		int result = a+b;
		System.out.println("("+i+")"+a+"+"+b+"=");
		
		System.out.println("算吧---(提示:输入-1可提前结束)");
		int answer =scan.nextInt();
		
		if(answer == 1){
			break;
		}
		if (answer == result){
			System.out.println("答对了!");
			score +=10;
		}else{
			System.out.println("答错了!");
		}
		
	}
	System.out.println("得分为:"+score);
©️2020 CSDN 皮肤主题: 创作都市 设计师:CSDN官方博客 返回首页