Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 9 of 9

Thread: What is wrong with my code

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default What is wrong with my code

    Hi guys i can't work out what is wrong with my code here
    public class Student
    {
        // instance variables - replace the example below with your own
        private String Id;
        private String stuName;
        private int gradeAverage;
     
         /**
         * Constructor for objects of class Student
         */
          public Student()
         {
             // initialise instance variables
             Id = "20054425";
             stuName = "Marco Perrozzi";
             gradeAverage = 80;
         }
     
     
         public Student(String Id, String stuName, int gradeAverage)
         {
            // initialise instance variables
            Id = Id;
            stuName = stuName;
            gradeAverage = gradeAverage;
         }
     
         public String getId()           { return Id;}
     
         public String getstuName()      {return stuName;}
     
         public int getgradeAverage()       {return gradeAverage;}
     
        }


    THAT NEEDS TO LINK UP WITH THIS

    public class StudentClient
    {
        public static void main(String args[]){
     
            Student defaultStudent = new Student("12345", "Marco P", 90);
     
            System.out.println("Default student Id is: "+defaultStudent.getId());
            System.out.println("Default Student Name is: "+defaultStudent.getstuName());
            System.out.println("Default Grade average is: "+defaultStudent.getgradeAverage());
     
            defaultStudent.SetId("3546737");
            defaultStudent.setstuName("John D");
            defaultStudent.setgradeAverage(35);
     
          //  System.out.println("Default student Id is: "+infoStudent());
            System.out.println("Info student Id is: "+ defaultStudent.getId());
            System.out.println("Info Student Name is: "+ defaultStudent.getstuName());
            System.out.println("Info Grade average is: "+ defaultStudent.getgradeAverage());
     
     
     
        }
    }

    So what am i doing wrong and what are the mistakes ?

    Thanks


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: What is wrong with my code

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.

    what is wrong with my code
    Please explain why you think there is something wrong.
    Copy and post here something that shows the problem. Be sure to add some comments saying what is wrong.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Feb 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: What is wrong with my code

    Sorry i am only new to the site and i am trying to see how to use it and have it edited and fixed there

    This is the error i am getting in Student Client

    Cannot find symbol method setID (java.lang.string.);

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: What is wrong with my code

    Where is that method defined?

    NOTE: java is case sensitive. There are two errors in what you posted:
    Cannot find symbol method setID (java.lang.string.);
    Both setId and string are spelled differently in the code.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Feb 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: What is wrong with my code

    So i need to change to all Caps ?

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: What is wrong with my code

    No. The variables and class names need to be spelled correctly. Look at the API doc for the correct spelling.

    Where is the setId method defined in the Student class?
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Member Ganeprog's Avatar
    Join Date
    Jan 2014
    Location
    Chennai,India
    Posts
    80
    My Mood
    Love
    Thanks
    3
    Thanked 6 Times in 6 Posts

    Default Re: What is wrong with my code

    Hi,

    Where you defined getter(getId(),getstuName(),getgradeAverage()) and setter(setId(),setstuName(),setgradeAverage()) methods. Please post the full code here.

    Thanks

  8. #8
    Junior Member
    Join Date
    Feb 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: What is wrong with my code

    Thats my full code Am i missing code ?

  9. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: What is wrong with my code

    You keep ignoring this question:

    Where is the setId method defined in the Student class?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. What's wrong with my code?
    By ZorraBella in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 20th, 2013, 09:37 PM
  2. What's wrong with my code?
    By cbplayer in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 13th, 2013, 03:07 PM
  3. What Am I doing Wrong In This Code?
    By RadiusUnknown in forum What's Wrong With My Code?
    Replies: 0
    Last Post: November 14th, 2012, 04:00 PM
  4. What is wrong with my code?
    By dannyboi in forum What's Wrong With My Code?
    Replies: 5
    Last Post: July 23rd, 2012, 02:40 PM
  5. What is wrong with this code?
    By A19 in forum What's Wrong With My Code?
    Replies: 15
    Last Post: August 11th, 2011, 09:45 PM