#Java CoinMachine homework help

3 messages · Page 1 of 1 (latest)

stiff mason
#

Hello everybody! I am a student in Uni with zero coding experience! I got this assignment with a deadline and I need help if possible! I am really stuck!

I am using Eclpise IDE for Java as well.

Question 1: Coin Machine Program (100 points)
Write your program in a java file called CoinMachine.java. Your program must determine the amount
of change that would be returned by a coin machine given the amount of money dropped into the machine
by a customer (call it the cash) and the cost of the item wanted by the customer (call it the price).
Assume that the change will be composed of toonies, loonies, quarters, dimes, and nickels. Assume also
that:
• The amount of money dropped into the machine by the customer will always be equal to or greater
than the cost of the item.
• Amounts are considered to be integer amounts in cents. For example, $2.75 is represented by the
integer 275.
• Amounts will always be multiples of 5 (i.e. pennies are not considered).
• Your coin machine has an infinite number of each type of coin with which to supply change.
Note that, to be considered correct, your program must provide the user with the most convenient exact
change (i.e. the exact amount with the fewest coins).
Write Java code in the marked area of the provided file to display the following information:

  1. The amount received by the coin machine.
  2. The cost of the item.
  3. The required change.
  4. How many of each of the coins will be returned by the coin machine.
    Let’s look at three examples:
  5. If the program is run with input arguments 400 and 215 (that is the item costs $2.15 and the
    customer dropped $4.00 into the machine) then the output should be:
    Amount received: 400
    Cost of the item: 215
    Required change: 185
    Change:
    toonies x 0
    loonie x 1
    quarter x 3
    dime x 1
    nickel x 0
    Note that, for instance, a solution of toonie x 0, loonie x 0, quarter x 7, dime x 1, nickel x 0 is not
    considered correct.
    Note: Toonie = $2, Loonie = $1, Quarter = 25 ¢, Dime = 10 ¢, Nickel = 5 ¢.
safe nymphBOT
#

This post has been reserved for your question.

Hey @stiff mason! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.