我是Java編程的初學者,我想知道:它是什麼意思或它的功能: obtainMarks = se.nextInt(); 在此代碼:java:它是什麼意思呢:acquiredMarks = se.nextInt();
package ifstatment;
import java.util.Scanner;
public class Ifstatment {
public static void main(String[] args) {
int obtainedMarks ;
int passingMarks;
String grade;
Scanner se = new Scanner(System.in);
System.out.println("Enter your scoor");
passingMarks = 40 ;
obtainedMarks = se.nextInt();
if (obtainedMarks >= passingMarks){
if (obtainedMarks > 90)
grade = "A";
else if (obtainedMarks > 75)
grade = "B";
else if (obtainedMarks > 65)
grade = "C";
else
grade ="D";
System.out.println("You passed the exam and your grade is"+ grade);
} else {
grade = "F";
System.out.println("You failed in thee exam and your grade is " + grade);
}
}
}
它只是從'System.in'中讀取下一個整數,即控制檯輸入並將其保存到'obtainMarks'(順便說一下,這不是一個好名字,'obtainMark'會更有意義。 – GiantTree