我有這樣一個任務:Java輸入,掃描儀和if語句
寫一個完整的程序稱爲ExamResult與行爲如下所示。 閱讀用戶輸入內容,瞭解學生的內部考試分數和期末考試分數。
內部測試分數低於20會導致學生失敗; 40以下的最終考試成績也會導致學生失敗。
否則學生已通過。
學期考試成績!
你的內部測試分數是多少? 21
你的期末考試分數是多少? 69
你已經通過了!
到目前爲止,我已經發現使用if語句和掃描器進行輸入是合適的。 現在這是我的代碼(我有課,進口的Java UTIL及以上主梅索德。我選擇不包括在這裏)
System.out.println("Semester Examination Results!");
System.out.println("What is your internal test score?");
//input
//calculate input
//does input pass the if test?
//output passed/failed
int score1 = scanner.nextLine();
int score2 = scanner.nextLine();
if (int score1 < 20; || score2 < 40;)
{
System.out.println("You have failed");
}
else
{
System.out.println("You have passed");
}
我不確定什麼是如何使用輸入計算?
'if(int score1 <20; || score2 <40;)'不會很好地結束。刪除';'和'int'。 – Bathsheba
我強烈建議閱讀初學者的java教程,然後在Stack Overflow上發佈問題。提問「經過深入研究」的基本問題是可以的:) – TheLostMind
我一遍又一遍地閱讀我的書,並試圖研究,它只是因爲它太新了,所以我很容易發作:P –