java - Creating a class to record student grades -


i know there quite few errors in code, can't find them/don't understand them. doing wrong?

update: thank help. have managed clear out errors except one. still errors on getgradescore.

error: cannot find symbol

error: illegal start of type


public class studentrecord {     /***declarations**/      private int quizscore1;     private int quizscore2;     private int quizscore3;                 private int midtermscore;     private int finalscore;      /***accessor methods**/      public int getquizscore1()     {         return quizscore1;     }      public int getquizscore2()     {         return quizscore2;     }      public int getquizscore3()     {         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);     }      /***equals methods***/      public boolean equalsquizscore1 (int otherquizscore1)     {         return (quizscore1 == otherquizscore1);     }      public boolean equalsquizscore2 (int otherquizscore2)     {         return (quizscore2 == otherquizscore2);     }      public boolean equalsquizscore3 (int otherquizscore3)     {         return (quizscore3 == otherquizscore3) ;     }      public boolean equalsmidtermscore (int othermidtermscore)     {         return (midtermscore == othermidtermscore);     }      public boolean equalsfinalscore (int otherfinalscore)     {          return (finalscore == otherfinalscore);     }      /***get grade methods***/      public int getgradescore()     {         int gradescore;          gradescore = (((quizscore1 + quizscore2 + quizscore3) / 3) / 10 * 25) + (midtermscore / 100 * 35) + (finalscore / 100 * 40);           return gradescore;     }      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()     {         int gradescore;         char lettergrade;          return ("grade score " + gradescore + "and letter grade " + lettergrade);     }  } 

any appreciated! i've spent hours on , can't figure out. i'm confused classes , methods.

if try compile code you'll ton of syntax errors. here 3 of major offenders found , proposed solutions

1) quizscore1, quizscore2, , quizscore3 undeclared. do, however, have quizscore variable. if want store 3 quizscores, can either make list of scores, or can declare them. suggest arraylist. you'll need add more functions, 1 each score.

2) public boolean equals (otherquizscore) not allowed. type of otherquizscore? add type.

3) multiple return statements. return statement end function. if have 3 return statements in row, second 2 never run.

there slew of errors in code. if put ide (i suggest eclipse if don't have it) you'll see each error marked red underline, corresponding error message.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -