import java.util.Scanner;
import java.util.Random;
public class W010 {
public static void main(String[] args) {
//定义变量程序随机出10道10以内的加法题,由用户输入答案,每答完一题,
//程序判断对错,并提示"答对了","答错了"。10题完全答完,
//系统提示10题中答对的题数并计算总分
//定义变量
int a=0,b=0,score=0,right=0,wrong=0,x=0,y=0;
//输入准备
Scanner sc=new Scanner(System.in);
Random rand = new Random();
//程序处理
for(int i=1;i<=10;i++) {
a = rand.nextInt(10)+1;
b = rand.nextInt(10)+1;
int s = a+b;
System.out.println("请计算第"+i+"道题,"+a+"+"+b+"=");
int n = sc.nextInt();
if(n==s) {
right+=10;
x++;
System.out.println("答对了");
}else {
wrong+=10;
System.out.println("答错了");
y++;
}
}
System.out.println("答对了"+x+"道题,得分为"+right+",答错了"+y+"道题,扣"+wrong+"分");
}
}