APCS-A Java Classwork: Coin Dispenser
Create two files:  CoinDispenser.java and CoinCall.java

CoinDispenser.java
  • a constructor class (no 'main' method and no keyword 'static')
  • simulates a cash register change machine that automatically dispenses coins
  • contains a single constructor
    - takes one argument, the number of cents to be dispensed
  • contains a non-static method named "calculate"
    - takes no arguments
    - dispenses the fewest number of coins possible
    - displays the number of quarters, dimes, nickels, and pennies to be dispensed
    - creates neatly-formatted output, similar to what is shown below
    - does not return anything

CoinCall.java
  • a calling class
  • uses the "Scanner" class
  • does not perform any error trapping
  • contains a 'main' method
    - asks for, and gets from the user, an integer number of cents
    - creates a "CoinDispenser" object using the supplied number of cents
    - calls the "calculate" method in the "CoinDispenser" class


As always, all of your code must be your own, written entirely and
only by you within your online CodeHS.com account.  You must never
copy/paste, receive, view, or in any way use code that was created
or modified by another person, entity, or artificial intelligence.


Sample Program Run #1
=====================
Enter the amount of change (in cents):  37

 37 cents =>
  Quarters:    1
  Dimes:       1
  Nickels:     0
  Pennies:     2


Sample Program Run #2
=====================
Enter the amount of change (in cents):  168

 168 cents =>
  Quarters:    6
  Dimes:       1
  Nickels:     1
  Pennies:     3


Sample Program Run #3
=====================
Enter the amount of change (in cents):  11

 11 cents =>
  Quarters:    0
  Dimes:       1
  Nickels:     0
  Pennies:     1


Advanced Option
In your "CoinCall" class, in addition to having the user enter a single
integer representing an amount of cents, allow the user to enter two or
three integers, representing two or three separate amounts of cents,
respectively.  The user should enter these values all on one line, with
each value separated by one or more spaces (e.g., "37" or "37 168" or
"37   168  11").  And, in your "CoinDispenser" class, add two additional
constructors, one of which accepts two integer values, and the other new
constructor accepting three integer values.  Based on how many values the
user enters (one, two, or three), your "CoinCall" class should call the
appropriate constructor in the "CoinDispenser" class.  The "calculate"
method should then print one, two, or three independent sets of output.