Problem

Suppose you have a Town class that describes the demographics of small towns. The vital st...

Suppose you have a Town class that describes the demographics of small towns. The vital statistics described by this class are 

numberOfAdults
 and 
numberOfChildren.
 These vital statistics are encapsulated and not directly accessible from outside the class.

a) Write the following methods for 

class Town:

i. An

initialize
 method that establishes initial values of instance variables. Assume that
initialize
 gathers all the data it needs by prompting for and inputting values from a user.

ii. A

simulateBirth
 method that simulates the birth of one child.

iii. A 

printStatistics
 method that prints out the current vital statistics.

b) Write a 

main
 method for a separate driver class that does the following:

i. Creates a town named newHome

ii. Calls 

initialize
 to establish initial values of instance variables for 
newHome.

iii. Simulates the birth of a pair of twins.

iv. Prints out 

newHome’s
vital statistics.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 6
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT