我不得不在Java中的GPA計算器... 用戶將進入課程名稱,獲得商標及百分率... 和程序將輸出等級,等級分所有科目單獨
然後程序會輸出平均GPA ... 程序也將給出關於GPA的評論,就像它是4.0 .... Excelent將顯示在輸出...... 我不是要求代碼我只是想正確的指導,如何解決這個問題像我應該做什麼功能 或循環將被應用?(這種指導)?如何更正此代碼?
我已經試過這樣.....
import java.util.Scanner;
public class Calc {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter number of a Subjects");
int nm = sc.nextInt();
for(int i=0;i<=nm;i++)
{
System.out.println("Enter name of a Subject ");
String Sub1 = sc.next();
System.out.println("Enter the Obtained marks of a Subject");
int ObtM = sc.nextInt();
if(ObtM<40)
{
System.out.println("Grade is F");
System.out.println("GradePoint is 0");
System.out.println("Remarks=Fail");
}
else if(ObtM<=49&&ObtM>=40)
{
System.out.println("Grade is D");
System.out.println("GPA is 1");
System.out.println("Remarks=pass");
}
else if(ObtM<=50&&ObtM>=64)
{
System.out.println("Grade is C");
System.out.println("GPA is 2");
System.out.println("Remarks=Satisfactory");
}
else if(ObtM<=65&&ObtM>=79)
{
System.out.println("Grade is B");
System.out.println("GPA is 3");
System.out.println("Remarks=Good");
}
else if(ObtM<=80&&ObtM>=100)
{
System.out.println("Grade is A");
System.out.println("GPA is 4");
System.out.println("Remarks=Excellent");
}
int percentage=ObtM*100/100;
System.out.println("Percentage is "+percentage);
}
}
}
自己做你的任務! –
您當前的代碼以何種方式無法按預期工作?你卡在哪裏?我們很樂意回答具體問題,但我們不提供輔導服務。 – David
感謝這個美好的評論 –