“Variable declaratorid expected after this method” error in java class file










0















I'm looking for help on an error that I am getting while trying to create this java class. I want to add test scores as well as the average for this student class. I have tried a lot of things and I cant seem to get the error "Variable declaratorid expected after this method" to go away when I reach my setTestScore method shown below (shown with arrows) similarly in my next getTestScore method I have an error "cant invoke getTest() on the primitive type int." (also show with arrows)



 public class Student 

private String firstName, lastName;
private Address homeAddress, schoolAddress;
private int TestScore, testScores ;
private int testScore1, testScore2, testScore3;;

public void TestScore(int testScore1, int testScore2, int testScore3)

this.testScore1 = testScore1;
this.testScore2 = testScore2;
this.testScore3 = testScore3;



public Student(String first, String last, Address home, Address school)

this.firstName = first;
this.lastName = last;
this.homeAddress = home;
this.schoolAddress = school;




testScores = new TestScore(testScore1, testScore2, testScore3);

public void setTestScore(int testNumber, int TestScore)
if(testNumber==1)
testScores.setTest1(>>testScore<<);

else if(testNumber==2)
testScores.setTest2(>>testScore<<);

else if(testNumber==3)
testScores.setTest3(>>testScore<<);


public void setTest1(int test1)
this.testScore1 = test1;

public void setTest2(int test2)
this.testScore2 = test2;

public void setTest3(int test3)
this.testScore3 = test3;



public int getTestScore(int testNumber)

if(testNumber==1)
return >>testScores.getTest1<<();

else if(testNumber==2)
return >>testScores.getTest2<<();

else if(testNumber==3)
return >>testScores.getTest3<<();

else
return 0;


public int getTest1()
return testScore1;

public int getTest2()
return testScore2;

public int getTest3()
return testScore3;


public double getAverageTestScores()
double avg;

avg=(testScores.getTest1() + testScores.getTest2() + testScores.getTest3())/3.0;

return avg;


public String toString()

String result;

result = firstName + " " + lastName + "n";
result += "Home Address:n" + homeAddress + "n";
result += "School Address:n" + schoolAddress + "n";
result +="Test Score 1:n" + testScores.getTest1() + "n";
result +="Test Score 2:n" + testScores.getTest2() + "n";
result +="TestScore 3:n" + testScores.getTest3() + "n";
result +="Average test score:n" + getAverageTestScores() + "n";
return result;











share|improve this question


























    0















    I'm looking for help on an error that I am getting while trying to create this java class. I want to add test scores as well as the average for this student class. I have tried a lot of things and I cant seem to get the error "Variable declaratorid expected after this method" to go away when I reach my setTestScore method shown below (shown with arrows) similarly in my next getTestScore method I have an error "cant invoke getTest() on the primitive type int." (also show with arrows)



     public class Student 

    private String firstName, lastName;
    private Address homeAddress, schoolAddress;
    private int TestScore, testScores ;
    private int testScore1, testScore2, testScore3;;

    public void TestScore(int testScore1, int testScore2, int testScore3)

    this.testScore1 = testScore1;
    this.testScore2 = testScore2;
    this.testScore3 = testScore3;



    public Student(String first, String last, Address home, Address school)

    this.firstName = first;
    this.lastName = last;
    this.homeAddress = home;
    this.schoolAddress = school;




    testScores = new TestScore(testScore1, testScore2, testScore3);

    public void setTestScore(int testNumber, int TestScore)
    if(testNumber==1)
    testScores.setTest1(>>testScore<<);

    else if(testNumber==2)
    testScores.setTest2(>>testScore<<);

    else if(testNumber==3)
    testScores.setTest3(>>testScore<<);


    public void setTest1(int test1)
    this.testScore1 = test1;

    public void setTest2(int test2)
    this.testScore2 = test2;

    public void setTest3(int test3)
    this.testScore3 = test3;



    public int getTestScore(int testNumber)

    if(testNumber==1)
    return >>testScores.getTest1<<();

    else if(testNumber==2)
    return >>testScores.getTest2<<();

    else if(testNumber==3)
    return >>testScores.getTest3<<();

    else
    return 0;


    public int getTest1()
    return testScore1;

    public int getTest2()
    return testScore2;

    public int getTest3()
    return testScore3;


    public double getAverageTestScores()
    double avg;

    avg=(testScores.getTest1() + testScores.getTest2() + testScores.getTest3())/3.0;

    return avg;


    public String toString()

    String result;

    result = firstName + " " + lastName + "n";
    result += "Home Address:n" + homeAddress + "n";
    result += "School Address:n" + schoolAddress + "n";
    result +="Test Score 1:n" + testScores.getTest1() + "n";
    result +="Test Score 2:n" + testScores.getTest2() + "n";
    result +="TestScore 3:n" + testScores.getTest3() + "n";
    result +="Average test score:n" + getAverageTestScores() + "n";
    return result;











    share|improve this question
























      0












      0








      0








      I'm looking for help on an error that I am getting while trying to create this java class. I want to add test scores as well as the average for this student class. I have tried a lot of things and I cant seem to get the error "Variable declaratorid expected after this method" to go away when I reach my setTestScore method shown below (shown with arrows) similarly in my next getTestScore method I have an error "cant invoke getTest() on the primitive type int." (also show with arrows)



       public class Student 

      private String firstName, lastName;
      private Address homeAddress, schoolAddress;
      private int TestScore, testScores ;
      private int testScore1, testScore2, testScore3;;

      public void TestScore(int testScore1, int testScore2, int testScore3)

      this.testScore1 = testScore1;
      this.testScore2 = testScore2;
      this.testScore3 = testScore3;



      public Student(String first, String last, Address home, Address school)

      this.firstName = first;
      this.lastName = last;
      this.homeAddress = home;
      this.schoolAddress = school;




      testScores = new TestScore(testScore1, testScore2, testScore3);

      public void setTestScore(int testNumber, int TestScore)
      if(testNumber==1)
      testScores.setTest1(>>testScore<<);

      else if(testNumber==2)
      testScores.setTest2(>>testScore<<);

      else if(testNumber==3)
      testScores.setTest3(>>testScore<<);


      public void setTest1(int test1)
      this.testScore1 = test1;

      public void setTest2(int test2)
      this.testScore2 = test2;

      public void setTest3(int test3)
      this.testScore3 = test3;



      public int getTestScore(int testNumber)

      if(testNumber==1)
      return >>testScores.getTest1<<();

      else if(testNumber==2)
      return >>testScores.getTest2<<();

      else if(testNumber==3)
      return >>testScores.getTest3<<();

      else
      return 0;


      public int getTest1()
      return testScore1;

      public int getTest2()
      return testScore2;

      public int getTest3()
      return testScore3;


      public double getAverageTestScores()
      double avg;

      avg=(testScores.getTest1() + testScores.getTest2() + testScores.getTest3())/3.0;

      return avg;


      public String toString()

      String result;

      result = firstName + " " + lastName + "n";
      result += "Home Address:n" + homeAddress + "n";
      result += "School Address:n" + schoolAddress + "n";
      result +="Test Score 1:n" + testScores.getTest1() + "n";
      result +="Test Score 2:n" + testScores.getTest2() + "n";
      result +="TestScore 3:n" + testScores.getTest3() + "n";
      result +="Average test score:n" + getAverageTestScores() + "n";
      return result;











      share|improve this question














      I'm looking for help on an error that I am getting while trying to create this java class. I want to add test scores as well as the average for this student class. I have tried a lot of things and I cant seem to get the error "Variable declaratorid expected after this method" to go away when I reach my setTestScore method shown below (shown with arrows) similarly in my next getTestScore method I have an error "cant invoke getTest() on the primitive type int." (also show with arrows)



       public class Student 

      private String firstName, lastName;
      private Address homeAddress, schoolAddress;
      private int TestScore, testScores ;
      private int testScore1, testScore2, testScore3;;

      public void TestScore(int testScore1, int testScore2, int testScore3)

      this.testScore1 = testScore1;
      this.testScore2 = testScore2;
      this.testScore3 = testScore3;



      public Student(String first, String last, Address home, Address school)

      this.firstName = first;
      this.lastName = last;
      this.homeAddress = home;
      this.schoolAddress = school;




      testScores = new TestScore(testScore1, testScore2, testScore3);

      public void setTestScore(int testNumber, int TestScore)
      if(testNumber==1)
      testScores.setTest1(>>testScore<<);

      else if(testNumber==2)
      testScores.setTest2(>>testScore<<);

      else if(testNumber==3)
      testScores.setTest3(>>testScore<<);


      public void setTest1(int test1)
      this.testScore1 = test1;

      public void setTest2(int test2)
      this.testScore2 = test2;

      public void setTest3(int test3)
      this.testScore3 = test3;



      public int getTestScore(int testNumber)

      if(testNumber==1)
      return >>testScores.getTest1<<();

      else if(testNumber==2)
      return >>testScores.getTest2<<();

      else if(testNumber==3)
      return >>testScores.getTest3<<();

      else
      return 0;


      public int getTest1()
      return testScore1;

      public int getTest2()
      return testScore2;

      public int getTest3()
      return testScore3;


      public double getAverageTestScores()
      double avg;

      avg=(testScores.getTest1() + testScores.getTest2() + testScores.getTest3())/3.0;

      return avg;


      public String toString()

      String result;

      result = firstName + " " + lastName + "n";
      result += "Home Address:n" + homeAddress + "n";
      result += "School Address:n" + schoolAddress + "n";
      result +="Test Score 1:n" + testScores.getTest1() + "n";
      result +="Test Score 2:n" + testScores.getTest2() + "n";
      result +="TestScore 3:n" + testScores.getTest3() + "n";
      result +="Average test score:n" + getAverageTestScores() + "n";
      return result;








      java class methods






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 15 '18 at 6:45









      BriTheCyberGuy18BriTheCyberGuy18

      134




      134






















          2 Answers
          2






          active

          oldest

          votes


















          0














          remove this statement



          testScores = new TestScore(testScore1, testScore2, testScore3);


          and where ever you have used



          testScores.foo


          in your program,replace it with



          this.foo 





          share|improve this answer

























          • still gives the same error but only instead of underlining only the testScore it underlines the whole line testScores.setTest1(TestScore)

            – BriTheCyberGuy18
            Nov 15 '18 at 6:54











          • @BriTheCyberGuy18 hi, i have edited my response as you question is more clearer now based on the comments below. please check as this should work.

            – AppleCiderGuy
            Nov 16 '18 at 3:50



















          0














          remove this statement



          testScores = new TestScore(testScore1, testScore2, testScore3);


          and where ever you have used



          testScores.foo


          in your program,replace it with



          this.foo 





          share|improve this answer

























          • I mean: private TestScore testScores ;

            – XeWion
            Nov 15 '18 at 7:03











          • So that fixed one thing but now private TestScore has an error “can’t be resolved to a type” and the testscore every where else can’t be resolved as a type either. I’m really stumped. I know it’s probably something simple but I can’t figure it out

            – BriTheCyberGuy18
            Nov 15 '18 at 7:09











          • U don't have class named "TestScore" so you can't create type of this class. Create new class in project named "TestScore",

            – XeWion
            Nov 15 '18 at 9:13











          • that was my original plan that fixed everything but the problem for school that I'm trying to follow wants me to make it apart of the student class

            – BriTheCyberGuy18
            Nov 15 '18 at 16:20











          • @XeWion sorry i accidentally placed and edit request on your answer instead of editing mine. you can feel free to disregard it !

            – AppleCiderGuy
            Nov 16 '18 at 3:59










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53313826%2fvariable-declaratorid-expected-after-this-method-error-in-java-class-file%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          remove this statement



          testScores = new TestScore(testScore1, testScore2, testScore3);


          and where ever you have used



          testScores.foo


          in your program,replace it with



          this.foo 





          share|improve this answer

























          • still gives the same error but only instead of underlining only the testScore it underlines the whole line testScores.setTest1(TestScore)

            – BriTheCyberGuy18
            Nov 15 '18 at 6:54











          • @BriTheCyberGuy18 hi, i have edited my response as you question is more clearer now based on the comments below. please check as this should work.

            – AppleCiderGuy
            Nov 16 '18 at 3:50
















          0














          remove this statement



          testScores = new TestScore(testScore1, testScore2, testScore3);


          and where ever you have used



          testScores.foo


          in your program,replace it with



          this.foo 





          share|improve this answer

























          • still gives the same error but only instead of underlining only the testScore it underlines the whole line testScores.setTest1(TestScore)

            – BriTheCyberGuy18
            Nov 15 '18 at 6:54











          • @BriTheCyberGuy18 hi, i have edited my response as you question is more clearer now based on the comments below. please check as this should work.

            – AppleCiderGuy
            Nov 16 '18 at 3:50














          0












          0








          0







          remove this statement



          testScores = new TestScore(testScore1, testScore2, testScore3);


          and where ever you have used



          testScores.foo


          in your program,replace it with



          this.foo 





          share|improve this answer















          remove this statement



          testScores = new TestScore(testScore1, testScore2, testScore3);


          and where ever you have used



          testScores.foo


          in your program,replace it with



          this.foo 






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 16 '18 at 3:52

























          answered Nov 15 '18 at 6:49









          AppleCiderGuyAppleCiderGuy

          711311




          711311












          • still gives the same error but only instead of underlining only the testScore it underlines the whole line testScores.setTest1(TestScore)

            – BriTheCyberGuy18
            Nov 15 '18 at 6:54











          • @BriTheCyberGuy18 hi, i have edited my response as you question is more clearer now based on the comments below. please check as this should work.

            – AppleCiderGuy
            Nov 16 '18 at 3:50


















          • still gives the same error but only instead of underlining only the testScore it underlines the whole line testScores.setTest1(TestScore)

            – BriTheCyberGuy18
            Nov 15 '18 at 6:54











          • @BriTheCyberGuy18 hi, i have edited my response as you question is more clearer now based on the comments below. please check as this should work.

            – AppleCiderGuy
            Nov 16 '18 at 3:50

















          still gives the same error but only instead of underlining only the testScore it underlines the whole line testScores.setTest1(TestScore)

          – BriTheCyberGuy18
          Nov 15 '18 at 6:54





          still gives the same error but only instead of underlining only the testScore it underlines the whole line testScores.setTest1(TestScore)

          – BriTheCyberGuy18
          Nov 15 '18 at 6:54













          @BriTheCyberGuy18 hi, i have edited my response as you question is more clearer now based on the comments below. please check as this should work.

          – AppleCiderGuy
          Nov 16 '18 at 3:50






          @BriTheCyberGuy18 hi, i have edited my response as you question is more clearer now based on the comments below. please check as this should work.

          – AppleCiderGuy
          Nov 16 '18 at 3:50














          0














          remove this statement



          testScores = new TestScore(testScore1, testScore2, testScore3);


          and where ever you have used



          testScores.foo


          in your program,replace it with



          this.foo 





          share|improve this answer

























          • I mean: private TestScore testScores ;

            – XeWion
            Nov 15 '18 at 7:03











          • So that fixed one thing but now private TestScore has an error “can’t be resolved to a type” and the testscore every where else can’t be resolved as a type either. I’m really stumped. I know it’s probably something simple but I can’t figure it out

            – BriTheCyberGuy18
            Nov 15 '18 at 7:09











          • U don't have class named "TestScore" so you can't create type of this class. Create new class in project named "TestScore",

            – XeWion
            Nov 15 '18 at 9:13











          • that was my original plan that fixed everything but the problem for school that I'm trying to follow wants me to make it apart of the student class

            – BriTheCyberGuy18
            Nov 15 '18 at 16:20











          • @XeWion sorry i accidentally placed and edit request on your answer instead of editing mine. you can feel free to disregard it !

            – AppleCiderGuy
            Nov 16 '18 at 3:59















          0














          remove this statement



          testScores = new TestScore(testScore1, testScore2, testScore3);


          and where ever you have used



          testScores.foo


          in your program,replace it with



          this.foo 





          share|improve this answer

























          • I mean: private TestScore testScores ;

            – XeWion
            Nov 15 '18 at 7:03











          • So that fixed one thing but now private TestScore has an error “can’t be resolved to a type” and the testscore every where else can’t be resolved as a type either. I’m really stumped. I know it’s probably something simple but I can’t figure it out

            – BriTheCyberGuy18
            Nov 15 '18 at 7:09











          • U don't have class named "TestScore" so you can't create type of this class. Create new class in project named "TestScore",

            – XeWion
            Nov 15 '18 at 9:13











          • that was my original plan that fixed everything but the problem for school that I'm trying to follow wants me to make it apart of the student class

            – BriTheCyberGuy18
            Nov 15 '18 at 16:20











          • @XeWion sorry i accidentally placed and edit request on your answer instead of editing mine. you can feel free to disregard it !

            – AppleCiderGuy
            Nov 16 '18 at 3:59













          0












          0








          0







          remove this statement



          testScores = new TestScore(testScore1, testScore2, testScore3);


          and where ever you have used



          testScores.foo


          in your program,replace it with



          this.foo 





          share|improve this answer















          remove this statement



          testScores = new TestScore(testScore1, testScore2, testScore3);


          and where ever you have used



          testScores.foo


          in your program,replace it with



          this.foo 






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 16 '18 at 8:16









          AppleCiderGuy

          711311




          711311










          answered Nov 15 '18 at 7:02









          XeWionXeWion

          11




          11












          • I mean: private TestScore testScores ;

            – XeWion
            Nov 15 '18 at 7:03











          • So that fixed one thing but now private TestScore has an error “can’t be resolved to a type” and the testscore every where else can’t be resolved as a type either. I’m really stumped. I know it’s probably something simple but I can’t figure it out

            – BriTheCyberGuy18
            Nov 15 '18 at 7:09











          • U don't have class named "TestScore" so you can't create type of this class. Create new class in project named "TestScore",

            – XeWion
            Nov 15 '18 at 9:13











          • that was my original plan that fixed everything but the problem for school that I'm trying to follow wants me to make it apart of the student class

            – BriTheCyberGuy18
            Nov 15 '18 at 16:20











          • @XeWion sorry i accidentally placed and edit request on your answer instead of editing mine. you can feel free to disregard it !

            – AppleCiderGuy
            Nov 16 '18 at 3:59

















          • I mean: private TestScore testScores ;

            – XeWion
            Nov 15 '18 at 7:03











          • So that fixed one thing but now private TestScore has an error “can’t be resolved to a type” and the testscore every where else can’t be resolved as a type either. I’m really stumped. I know it’s probably something simple but I can’t figure it out

            – BriTheCyberGuy18
            Nov 15 '18 at 7:09











          • U don't have class named "TestScore" so you can't create type of this class. Create new class in project named "TestScore",

            – XeWion
            Nov 15 '18 at 9:13











          • that was my original plan that fixed everything but the problem for school that I'm trying to follow wants me to make it apart of the student class

            – BriTheCyberGuy18
            Nov 15 '18 at 16:20











          • @XeWion sorry i accidentally placed and edit request on your answer instead of editing mine. you can feel free to disregard it !

            – AppleCiderGuy
            Nov 16 '18 at 3:59
















          I mean: private TestScore testScores ;

          – XeWion
          Nov 15 '18 at 7:03





          I mean: private TestScore testScores ;

          – XeWion
          Nov 15 '18 at 7:03













          So that fixed one thing but now private TestScore has an error “can’t be resolved to a type” and the testscore every where else can’t be resolved as a type either. I’m really stumped. I know it’s probably something simple but I can’t figure it out

          – BriTheCyberGuy18
          Nov 15 '18 at 7:09





          So that fixed one thing but now private TestScore has an error “can’t be resolved to a type” and the testscore every where else can’t be resolved as a type either. I’m really stumped. I know it’s probably something simple but I can’t figure it out

          – BriTheCyberGuy18
          Nov 15 '18 at 7:09













          U don't have class named "TestScore" so you can't create type of this class. Create new class in project named "TestScore",

          – XeWion
          Nov 15 '18 at 9:13





          U don't have class named "TestScore" so you can't create type of this class. Create new class in project named "TestScore",

          – XeWion
          Nov 15 '18 at 9:13













          that was my original plan that fixed everything but the problem for school that I'm trying to follow wants me to make it apart of the student class

          – BriTheCyberGuy18
          Nov 15 '18 at 16:20





          that was my original plan that fixed everything but the problem for school that I'm trying to follow wants me to make it apart of the student class

          – BriTheCyberGuy18
          Nov 15 '18 at 16:20













          @XeWion sorry i accidentally placed and edit request on your answer instead of editing mine. you can feel free to disregard it !

          – AppleCiderGuy
          Nov 16 '18 at 3:59





          @XeWion sorry i accidentally placed and edit request on your answer instead of editing mine. you can feel free to disregard it !

          – AppleCiderGuy
          Nov 16 '18 at 3:59

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53313826%2fvariable-declaratorid-expected-after-this-method-error-in-java-class-file%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          How to read a connectionString WITH PROVIDER in .NET Core?

          Node.js Script on GitHub Pages or Amazon S3

          Museum of Modern and Contemporary Art of Trento and Rovereto