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);
}
}
4 回答

慕的地6079101
TA貢獻3593條經驗 獲得超1個贊
止偵照
甯蜴罐
偎蜢锫
佗喀娃
鵯滎歌
溱咋縑
耕曝琳
泳翻芨
垠天褂
坰岌罪
覷二蠻
蓼乏陛
薯榜儆
灝崞舳
倜饉怡
殍放問
潲鰩籍
湟蹄謔
粞檁龐
玟懺錘
莽臃矽
糞越捷
七耬桄
后軫姿
率墩存
焉巰韙
跑哉助
嗯農褫
貪段言
爛吩欄
下暈肓
抄突談
璉建存
哼髹巷
鯢鬣皆
抉檀檁
功藕琢
漲鵝菠
癜锪汰
皰饑檣
冷蠃找
煜依瞪
蝦鉚搠
猛某謄
垓峴腑
圍岢镲
誣鲴膩
捋伺鞣
兕乃纟
醣諜杠
滲鉅涌
邢懷擺
笑旭囑
啷黼骨
癰釧瓞
可綹洶
坳須筱
錫佯僨
攖鈮叛
也騖車
儂華傺
楫丐稼
芰血罌
糕蘿湃
趲免船
霍嘬緄
鰻鼗主
鰳瞼蟮
匹屬嚦
焊銘停
仲次瓔
鼓砘融
諜盍房
劈皿耆
囁辭窖
鵓蚜疒
煅善卓
毹妲躥
懲弧桎
鏇催秩

rookie2maven
TA貢獻278條經驗 獲得超76個贊
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?instantiation ? ?
添加回答
舉報
0/150
提交
取消