package calculator; public class Question { int number; public int result[]; public void question(int a){ number=a; for(int i=1;i<=number;i++){ int x=(int)(Math.random()*10); int y=(int)(Math.random()*10); System.out.println(x+"+"+y+"= "); result[i]=x+y; } } } package calculator; import java.util.Scanner; public class Answer extends Question{ int answer[]; int point; public void result(){ Scanner a=new Scanner(System.in); { for(int i=1;i<number;i++) answer[i]=a.nextInt(); } { for(int i=1;i<number;i++) if(answer[i]==result[i]) { System.out.println("这个结果是对的"); point++; } else System.out.println("这个结果是错的"); } a.close(); } public int getResult(){ return point; } } package calculator; import java.util.Scanner; public class Maincalculator { public static void main(String[] args) { System.out.println("今天你想在学习的海洋中翱翔几道题呢?"); Scanner input=new Scanner(System.in); int sea=input.nextInt(); input.close(); System.out.println("哈哈,你居然只做"+sea+"道,你还差得远呢!不过还是如你所愿"); Question ques=new Question(); ques.question(sea); Answer ans=new Answer(); ans.result(); int score=ans.getResult(); System.out.println("你的分数是"+score); } }
慕的地6079101
Jamespan
rookie2maven
饿是你爸爸
二部学习小组
_潇潇暮雨