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: Homework help plz!!!

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    23
    My Mood
    Daring
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question Homework help plz!!!

    I'm doing an assignment that has multiple classes that inherit from one another. That part I get, and the majority of my code is correct as I spoke to my prof and went over what I had at the time. The problem I'm having now is making sure the code I'm adding to is correct according to what she's asking for.



    public class CreditStudent extends Student {
     
    //(These are the instructions) override totalCredits so that only credits from classes the student passed are counted
     
    @Override
        public int totalCredits() {
            int j = 0;
            for (int i = 0; i < firstEmpty; i++) {
                Student S1 = new Student();
              j += S1.Course[i].getCredits();  
            } 
          return j;
        }

    I want to make sure that my code says that only the credits the student has taken are being counted...am I missing something? If so, what am I missing...thanks in advance!


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

    Default Re: Homework help plz!!!

    what am I missing
    Please explain why you think something is missing. Is the output wrong?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Mar 2013
    Posts
    23
    My Mood
    Daring
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Homework help plz!!!

    no the output isn't missing...I don't think anyway...I just wanted to make sure that the IDEA behind the coding is correct lol...I like to plan ahead you know lol

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

    Default Re: Homework help plz!!!

    just wanted to make sure that the IDEA behind the coding is correct
    What is the IDEA behind the code that was posted? Do you have a list of steps the code is supposed to do to solve the problem?
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Mar 2013
    Posts
    23
    My Mood
    Daring
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Homework help plz!!!

    The IDEA of the code is to override totalCredits so that only credits from classes the student passed are counted...I think I need an if statement since it's a conditional right? I already have my instance var for all the other stuff from the other Classes needed

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

    Default Re: Homework help plz!!!

    only credits from classes the student passed are counted.
    What are the steps the code must take to do that?
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Mar 2013
    Posts
    23
    My Mood
    Daring
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Homework help plz!!!

    I think that's what we need to figure out lol...I have the all the other classes since the basis of the lesson is inheritance and how they work and what not. I have my passed method in another class but it's not the one that's inherited to this class...because those are the instructions she stipulated am I making sense? Because if you really need me to, than I'll of course POST all the classes and ALL the code that I have for the assignment

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Homework help plz!!!

    If you are working on the totalCredits() method now, there probably isn't any need to post the other code.
    What is the method supposed to return? How does it find/compute that value?
    Where are the values that are to be summed? Are all of the values to be added to the sum or only some of them?

    I'm done for tonight.
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Mar 2013
    Posts
    23
    My Mood
    Daring
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Homework help plz!!!

    Ok...I'll consider and work through the questions you asked...maybe that will help I can certainly leave as is and when I run the file see what happens...Thx for your help Norm

Similar Threads

  1. Help with homework
    By gta1 in forum Object Oriented Programming
    Replies: 1
    Last Post: March 11th, 2013, 08:58 PM
  2. Help with my homework?
    By mshem in forum Java Theory & Questions
    Replies: 2
    Last Post: November 16th, 2012, 03:15 AM
  3. Simple Java Homework : Due Wendsday Afternoon PLZ HELP!
    By chatok90 in forum What's Wrong With My Code?
    Replies: 9
    Last Post: November 30th, 2011, 05:58 PM
  4. Homework
    By jdonaldson in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 9th, 2011, 11:09 AM
  5. need help with homework!
    By programmer12345 in forum Java Theory & Questions
    Replies: 2
    Last Post: September 27th, 2009, 05:34 AM