java - Homework: Class to record Student Grades -
homework question
write grading program class following grading policies: a) 3 quizzes graded out of 10 points, weighted 25% b) 1 midterm graded out of 100 points, weighted 35% c) 1 final graded out of 100 points, weighted 40% class requires set of accessor , mutator methods, full constructor, default constructor, equals method, , string method. class should have instance variables quizzes, midterm, , final only. then, write tester program should read student's scores , output student's scores , student's record. student's overall numeric score entire course , final letter grade.
i keep getting errors no matter do! errors "error: cannot find symbol" glad if me figure out wrong. have spent hours on this.
these methods...
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 " + gradescore + "and letter grade " + lettergrade); } }
...and tester program...
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(); } }
you can not return multiple statement here.i think sum of quiz. make sum , return.
public int getquizscore() { return quizscore1; return quizscore2; return quizscore3; }
instead of
public int getquizscore() { return quizscore1+quizscore2+quizscore3; }
Comments
Post a Comment