亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

這個程序應該怎么改正確啊

這個程序應該怎么改正確啊

慕粉4223648 2016-11-01 10:46:12
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); } }
查看完整描述

1 回答

已采納
?
望遠

TA貢獻1017條經驗 獲得超1032個贊

你這樣貼代碼看著好累啊

//int?answer[];
和public?int?result[];

沒有實例化出來


查看完整回答
1 反對 回復 2016-11-01
  • 1 回答
  • 0 關注
  • 1095 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號