Question: 1. Your programming and documentation style should conform to the guidelines we have discussed. 2.Please complete the class with the name PiggyBankby following the directions

1.

Your programming and documentation style should conform to the guidelines we have

discussed.

2.Please complete the class with the name PiggyBankby following the directions below:

a.The following integer fields:

i.numPennies

ii.numNickels

iii.numDimes

iv.numQuarters

b.And a constructor that should initialize all fields to zero.

c.And the following mutator methods:

i.addPennies

ii.addNickels

iii.addDimes

iv.addQuarters

where the number of coins to be added is in the parameter. Note that if a negativenumber in passed to any of these methods, that value should

NOT be added to the appropriate field.

d. And an accessor method: i. getContents which returns how much is in the piggy bank. This method will require a local

variable for adding all the values together and returning a floating point value of the

dollar amount. There will be some arithmetic performed in this method.

e. And the following method is a combination of a mutator and an accessor:

i. breakTheBank where the contents are returned as a floating point value and all fields are set back to

zero. In it there must be a call to the getContents method before all fields are set back to zero.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!