Question: Write a basic java program... - Create a class called BankChange, with contants for QUARTER, DIME, NICKEL, PENNY. It should have fields for the owner,

Write a basic java program...

- Create a class called BankChange, with contants for QUARTER, DIME, NICKEL, PENNY. It should have fields for the owner, numOfQuarters, numOfDimes, numOfNickels, numOfPennies.

- Add a default constructor that sets owner to "no one" and sets quarters/dimes/nicks/pennies to 0. Then .. Add a constructor that has one parameter representing the name of the new bank change's owner. A new bankchange with an owner also contains 0 quarters, 0 dimes, 0 nickels, and 0 pennies.

-Create a getter and setter for the owner name field. Then create getters for the 4 other fields.

-Create four methods called plusQuarters, plusDimes, plusNickels, plusPennies. Each has one parameter that specifies the number of coins being added to the bankchange. Each method should add the coin to the appropriate field in the bankchange. After that create a plusCoins methods, It should have four parameters: the first is a number of quarters, the second a number of dimes, the third a number of nickels, and the fourth a number of pennies. It should add all of those coins to the bankchange.

- Then create a method that gets the total value, getTotalValue, with no parameters, it should return the total value of all coins stored(in dollars) Create another method called resetBank with no parameters. It returns the total value of all coins stored in the bankchange, in dollars but also removes all the coins from the account and resets the counters to 0. Lastly create a method called printReport with no parameters. It should print out a nicely formatted printout of the number of Quarters / Dimes / Nickels / Pennies / and Total value(in dollars) -For the main method. Create a couple of BankChange instances to test the program, add different amounts of coins to each test and make sure you test all of the methods you created.

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!