I need to design an Ages class with fields to hold 3 ages and includes a constructor, accessor and mutator method. Also needed is a method that returns the average of the ages.
I also need to write a demo class that creates an instance of Ages class. The demo needs to ask the user to enter 3 ages to be stored in the Ages object. Then the demo displays the average of the ages, as reported by the ages object.
I've written the the 1st program, which compiles o.k. But, I'm not sure it is correct.
Can someone take a look at my 1st class to see if I've set it up properly? Also, can someone give me some direction on how to write the demo program?
The demo class needs to create "Ages" objects and use the methods you have defined. As written your demo just defines some variables and prints the "avgAge" - which is still 0 because you haven't done anything with it.
Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
This thread is more than three months old
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.