Suppose you have a Town class that describes the demographics of small towns. The vital statistics described by this class are
numberOfAdultsand
numberOfChildren.These vital statistics are encapsulated and not directly accessible from outside the class.
a) Write the following methods for
class Town:
i. An
initializemethod that establishes initial values of instance variables. Assume that
initializegathers all the data it needs by prompting for and inputting values from a user.
ii. A
simulateBirthmethod that simulates the birth of one child.
iii. A
printStatisticsmethod that prints out the current vital statistics.
b) Write a
mainmethod for a separate driver class that does the following:
i. Creates a town named newHome
ii. Calls
initializeto establish initial values of instance variables for
newHome.
iii. Simulates the birth of a pair of twins.
iv. Prints out
newHome’svital statistics.
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.