Project #44004 - Java code for a simple CoinStar machine

INSTRUCTIONS 

The goal of this project is to reinforce the concepts of user input/output, calculations, branching, and looping and to devise and implement algorithms according to defined specifications.

SPECIFICATION 

Write a Java program to simulate a coins-to-cash exchange machine as follows.  Begin a balance for the user of zero dollars and cents.  Continually prompt the user to deposit coins according to the following stipulations.  Allow unlimited deposits without asking beforehand how many there will be. Let the user quit using an appropriate non-numeric sentinel value.  Allow the user to enter deposits in any of the following formats at will. The entered deposits should be added to the balance in dollars and cents. Allow only positive deposits.  An integer followed by a space and the word quarter, nickel, dime, or penny. For example, 14 quarter, 7 dime, and 1 nickel would each be a valid input.  Allow combined deposits within a single input. For example, 3 dime 5 penny 1 dime would be a valid input.  Reject any individual part of the input that is not valid by reporting an error and continuing to process the remaining input.  Maintain the total balance without allowing any precision errors. This means do not use any floating point primitives.  Display the total balance at the beginning and after each deposit.  When the user is finished with deposits, display the following results calculated as necessary.  Display the total balance of the accumulated coins in dollars and cents.  Calculate and display a 9.1% exchange fee on the balance, rounded up if necessary.  Calculate and display the voucher value of the balance by withholding the exchange fee from it.  Denominate the voucher value into bills and coins and display the results as follows.  Use the simplest combination of twenty, ten, five, and one dollar bills and quarters, dimes, nickels, and pennies to “make change” for the voucher value.  Show how many of each denomination are used in descending order without the unused denominations.  When the above steps are finished, the program should end gracefully.  All outputs to the user should be very legible and the prompts should be user-friendly. Invalid inputs should be rejected with clear directions to the user.  You may use either the console or dialog windows for your user input/output as you see fit, although the console is sufficient.  Avoid all magic numbers in your code through judicious use of constants.  Use appropriate variable and constant names, good programming style, and comments where useful.  Note that you are not required to make the singularity/plurality of the grammar correct. Just ensure that inputs are singular and outputs are plural, as in the example user experience on the next page, for consistency.   

 

2 / 2   

SAMPLE USER EXPERIENCE 

The following is an example of what the input/output might look like for a valid solution. You should not try to make your program look exactly like the example, but the example shows what an acceptable solution might approximate. Welcome to the Coin Exchanger.  

Deposits may be entered as the number of coins you are depositing followed by quarter, dime, nickel, or penny. When you are done depositing, please enter “cashout” to see your voucher.  

Enter a deposit: 7 quarter Deposited. Enter another: 5 dime Deposited. Enter another: 4 dime Deposited. Enter another: 9 penney Invalid deposit. Enter another: 9 penny Deposited. Enter another: 1 quarter Deposited. Enter another: 1 dime 2 nickel Deposited. Enter another: 1 quarter 1 nickel 1 quarter 5 penny Deposited. Enter another: cashout  

Your total balance: $3.79 Your exchange fee: $0.35 Your voucher after exchange fee: $3.44 Here is your voucher amount: 3 ones, 1 quarters, 1 dimes, 1 nickels, 4 pennies  

Thanks for using the Coin Exchanger. Please enjoy your imaginary money.  

Subject Computer
Due By (Pacific Time) 10/18/2014 05:00 pm
Report DMCA
TutorRating
pallavi

Chat Now!

out of 1971 reviews
More..
amosmm

Chat Now!

out of 766 reviews
More..
PhyzKyd

Chat Now!

out of 1164 reviews
More..
rajdeep77

Chat Now!

out of 721 reviews
More..
sctys

Chat Now!

out of 1600 reviews
More..
sharadgreen

Chat Now!

out of 770 reviews
More..
topnotcher

Chat Now!

out of 766 reviews
More..
XXXIAO

Chat Now!

out of 680 reviews
More..
All Rights Reserved. Copyright by AceMyHW.com - Copyright Policy