Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this program you will make change for a dollar using the most efficient set of coins possible. In Part A you will give the

In this program you will make change for a dollar using the most efficient set of coins possible. In Part A you will give the fewest quarters, dimes, nickels, and pennies possible and will code two separate methods to achieve this: one using an algorithm that adds coins until the desired amount is reached and one which uses a division method. In Part B you will make several changes, including raising the limit of change that can be returned, adding the possibility (option) of giving half-dollars, and randomizing which of the algorithms are used to produce the results. Part A: Basic Change for a dollar: In this version of the program you will give change for up to a dollar in the most efficient manner (i.e., fewest number of coins of each type). A sample run of the program might look as follows: Welcome to the Make Change calculator! What value would you like change for? (1-100 cents, or 0=quit): 23 For 23 cent(s) I give: 0 quarters, 2 dimes, 0 nickels, 3 pennies What value would you like change for? (1-100 cents, or 0=quit): 1 For: 1 cent(s) I give: 0 quarters, 0 dime, 0 nickels, 1 pennies What value would you like change for? (1-100 cents, or 0=quit): 100 For: 100 cent(s) I give: 4 quarters, 0 dime, 0 nickels, 0 pennies What value would you like change for? (1-100 cents, or 0=quit): 0 Thanks for using the Make Change calculator! Part A Required Elements: the following features must be present for full credit: Declare as global only those items that must be used across methods Minimize the code inside main, but include a loop so the user can enter change values multiple times (entry of a zero terminates the loop) Code a separate method to obtain and validate the input value as being from 0 to 100 Validation should include a try/catch structure to avoid crashing the program on non-integer input Code a separate method to determine and print the actual change returned Change is calculated using quarters, dimes, nickels, and pennies Part B: you will make the following changes to the program: You will raise the max value for change returned to 5 dollars (entered as 500 cents) Add the possibility of returning half-dollars. This will be done by a question asked one time, at the beginning of the session; a yes will cause the program to return half-dollars as part of the mix of coins given for all subsequent iterations Add a randomizing process that gives a 50/50 chance of using each of the algorithms developed in part A (the additive vs. the division algorithms) A sample run of the program might look as follows: Welcome to the Make Change calculator! Do you want to receive half-dollars? (Y/N): Y What value would you like change for? (1-100 cents, or 0=quit): 23 By the additive method, for 23 cent(s) I give: 0 quarters, 2 dimes, 0 nickels, 3 pennies What value would you like change for? (1-100 cents, or 0=quit): 78 By the division method, for: 78 cent(s) I give: 1 half-dollars, 1 quarters, 0 dimes, 0 nickels, 3 pennies What value would you like change for? (1-100 cents, or 0=quit): 100 By the division method, for: 100 cent(s) I give: 2 half-dollars, 0 quarters, 0 dimes, 0 nickels, 0 pennies What value would you like change for? (1-100 cents, or 0=quit): 0 Thanks for using the Make Change calculator! Part C: The program developed above will ultimately allow the user to enter an amount up to 500 cents, but will require the input to be done as integers only (i.e, whole number of cents). Instead, have the input method allow the user to enter dollars and cents in the usual way such as 1.55 for one dollar and fifty-five cents. This means that 5 would be the request for five dollars in change while .05 would be a request for 5 cents. Call the program MakeChange.java and zip the finished netbeans project from the top-level folder. Submit it through blackboard as a separate zip file

cannot figure out how to do the divmethod? Any help greatly appreciated.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions