家庭作业问题
使用以下评分政策为课程编写评分程序: a)3个测验评分为10分,加权25% b)1个中期评分满分100分,加权35% c)最终分数为100分,加权40% 您的类需要一组accessor和mutator方法,完整构造函数,默认构造函数,equals方法和String方法。该类应该只有测验,期中和最终的实例变量。 然后,编写一个测试程序,该程序应该读取学生的分数并输出学生的分数和学生的记录。以及学生整个课程和最终字母成绩的整体数字分数。
无论我做什么,我都会遇到错误!所有错误都是"错误:找不到符号"如果有人能帮我弄清楚什么是错的,我会很高兴的。我花了好几个小时。
这些是我的方法......
import java.util.Scanner;
public class StudentRecord
{
/***DECLARATIONS**/
private int quizScore1;
private int quizScore2;
private int quizScore3;
private int midtermScore;
private int finalScore;
/***ACCESSOR METHODS**/
public int getQuizScore()
{
return quizScore1;
return quizScore2;
return quizScore3;
}
public int getMidtermScore()
{
return midtermScore;
}
public int getFinalScore()
{
return finalScore;
}
/***MUTATOR METHODS**/
public void setQuizScore(int quizScore1, int quizScore2, int quizScore3)
{
if (quizScore1 < 0 || quizScore1 > 10)
{
System.out.println("Error: Invalid Quiz Grade");
}
if (quizScore2 < 0 || quizScore2 > 10)
{
System.out.println("Error: Invalid Quiz Grade");
}
if (quizScore3 <0 || quizScore3 > 10)
{
System.out.println("Error: Invalid Quiz Grade");
}
else
{
this.quizScore1 = quizScore1;
this.quizScore2 = quizScore2;
this.quizScore3 = quizScore3;
}
}
public void setMidtermScore(int midtermScore)
{
if (midtermScore < 0 || midtermScore > 100)
{
System.out.println("Error: Invalid Midterm Score");
}
else
{
this.midtermScore = midtermScore;
}
}
public void setFinalScore(int finalScore)
{
if (finalScore < 0 || finalScore > 100)
{
System.out.println("Error: Invalid Final Score");
}
else
{
this.finalScore = finalScore;
}
}
/***OTHER METHODS***/
public void studentRecord()
{
quizScore1 = 0;
quizScore2 = 0;
quizScore3 = 0;
midtermScore = 0;
finalScore = 0;
}
public void studentRecord(int quizScore1, int quizScore2, int quizScore3, int midtermScore, int finalScore)
{
System.out.println("Quiz Score 1: " + quizScore1);
System.out.println("Quiz Score 2: " + quizScore2);
System.out.println("Quiz Score 3: " + quizScore3);
System.out.println("Midterm Score: " + midtermScore);
System.out.println("Final Score: " + finalScore);
}
public boolean equals (StudentRecord otherStudentRecord)
{
return (quizScore1 == otherStudentRecord.quizScore1);
return (quizScore2 == otherStudentRecord.quizScore2);
return (quizScore3 == otherStudentRecord.quizScore3) ;
return (midtermScore == otherStudentRecord.midtermScore);
return (finalScore == otherStudentRecord.finalScore);
}
public int getGradeScore()
{
int gradeScore;
gradeScore = (((quizScore1 + quizScore2 + quizScore3) / 3) / 10 * 25) + (midtermScore / 100 * 35) + (finalScore / 100 * 40);
}
public char getLetterGrade()
{
int gradeScore;
char letterGrade;
if (gradeScore >= 90 && gradeScore <= 100)
{
return 'A';
}
else if (gradeScore >= 80 && gradeScore <= 89)
{
return 'B';
}
else if (gradeScore >= 70 && gradeScore <= 79)
{
return 'C';
}
else if (gradeScore >= 60 && gradeScore <= 69)
{
return 'D';
}
else
{
return 'F';
}
}
public String toString()
{
return ("Grade Score is " + gradeScore + "and letter grade is " + letterGrade);
}
}
......这是我的测试程序......
import java.util.Scanner;
public class CalculatingStudentGrade
{
public static void main(String[] args)
{
Scanner keyboard;
int quizScore1, quizScore2, quizScore3, midtermScore, finalScore;
keyboard = new Scanner(System.in);
System.out.println("Enter Quiz 1 score:");
quizScore1 = keyboard.nextInt();
System.out.println("Enter Quiz 2 score:");
quizScore2 = keyboard.nextInt();
System.out.println("Enter Quiz 3 score:");
quizScore3 = keyboard.nextInt();
StudentRecord.getQuizScore();
StudentRecord.getMidtermScore();
StudentRecord.getFinalScore();
StudentRecord.setQuizScore();
StudentRecord.setMidtermScore();
StudentRecord.setFinalScore();
StudentRecord.StudentRecord();
StudentRecord.getGradeScore();
StudentRecord.getLetterGrade();
}
}
答案 0 :(得分:0)
你不能在这里返回多个声明。我认为它将是所有测验的总和。所以把它归和,然后再回来。
public int getQuizScore()
{
return quizScore1;
return quizScore2;
return quizScore3;
}
而不是
public int getQuizScore()
{
return quizScore1+quizScore2+quizScore3;
}