-2
的非法啓動我目前在我高中的在線計算機科學類。我正在制定一個計劃,該計劃應該從外部文件中考慮幾名學生的成績,並計算學生獲得的最終百分比,以及通過使用駕駛員級別和主體類。 (請注意,每個學生有4個等級,一箇中期和一個最終測驗,測驗分數爲10分,相當於最終分數的25%,中期價值25%,最終價值50% )每次我嘗試編譯我的代碼時,它都會掛在一個用於確定最終字母等級的if循環上,我不知道它有什麼問題,非常感謝您的幫助。BlueJ的表達錯誤
主代碼
public class StudentRecord
{
private int quiz1;
private int quiz2;
private int midterm;
private int test;
private double finalpercent;
private char finalgrade;
public StudentRecord()
{
quiz1 = null;
quiz2 = null;
midterm = null;
test = null;
}
public StudentRecord(int t, int m, int q1, int q2)
{
quiz1 = q1*10;
quiz2 = q2*10;
midterm = m;
test = t;
}
public void setTest(int t)
{
test=t;
}
public void setMidterm(int m)
{
midterm=m;
}
public void setQuiz2(int q2)
{
quiz2=q2*10;
}
public void setQuiz1(int q1)
{
quiz1=q1*10;
}
public void setFinalPercent(int quiz1, int quiz2, int midterm, int test)
{
finalpercent = ((quiz1+quiz2)/2)*.25+midterm*.25+test*.5;
}
public void setFinalGrade(double finalpercent)
{
if (finalpercent => 90) THIS IS WHERE THE ERROR happens
{
finalgrade = A;
}
else if (finalpercent<=89&&finalpercent=>80)
{
finalgrade = B;
}
else if {finalpercent<=79&&finalpercent=>70}
{
finalgrade = C;
}
else if {finalpercent<=69&&finalpercent=>60}
{
finalgrade = D;
}
else
{
finalgrade = F;
}
}
public int getQuiz1()
{
return quiz1;
}
public int getQuiz2()
{
return quiz2;
}
public int getMidterm()
{
return midterm;
}
public int getTest()
{
return test;
}
public double getFinalPercent()
{
return finalpercent;
}
public char getFinalGrade()
{
return finalgrade;
}
public void inputinfo(Scanner.inFile)
{
private
}
}
驅動程序代碼
public class StudentRecordDriver
{
public static void main(String[] args)
{
Scanner inFIle = null;
try
{
inFile = new Scanner(new File("349f.txt"));
}
catch (FileNotFoundException e)
{
System.out.println("File not found");
System.exit(0);
}
System.out.pritnln("Studet\tQuiz1\tQuiz2\tMidTerm\tFinal\tFinal%\tGrade");
int student = 1;
while (inFile.hasNext())
{
String[] grades = inFile.nextLine().split(" ");
int quiz1 = Integer.valueOf(grade[0]);
int quiz2 = Integer.valueOf(grade[1]);
int midterm = Integer.valueOf(grade[2]);
int test = Integer.valueOf(grade[3]);
StudentRecord Student = new StudentRecord(int test, int midterm, int quiz1, int quiz2);
System.out.println(student+"\t"+student.getQuiz1+"\t"+student.getQuiz2+"\t"+student.getMidterm+"\t"+student.getTest+"\t"+student.getFinalPercent+"\t"+student.getFinalGrade);;
}
}
}
嘛'公共無效inputinfo(Scanner.inFile)'看起來並不有效,作爲一個開始......也不是身體的事實,只是'private'。 –
它是'> =',而不是'=>'。 – Andreas