import java.util.Scanner;
public class jisuan {
public static void main (String[] args){
Scanner sc=new Scanner(System.in);
int count=0;
for (int i=1;i<=10 ;i++ ){
int num1=(int)(Math.random()*100)+1;
int num2=(int)(Math.random()*100)+1;
System.out.println("第"+i+"题"+num1+"+"+num2+"=");
System.out.println("请输入你的答案,退出输入-1");
int sum=sc.nextInt();
if(sum==-1){
System.out.println("退出游戏");
break;
}else if((num1+num2)==sum){
count +=10;
System.out.println("回答正确!");
System.out.println("你目前的分数为:"+count);
}else{
System.out.println("回答错误!");
System.out.println("你目前的分数为:"+count);
continue;
}
}
System.out.println("测验结束,你的总分数是:"+count);
}
} |
|