Project7_making_change

# Step by step 1 prompt the user for the amount of

• Notes
• 3

This preview shows page 2 - 3 out of 3 pages.

erring on the side of finding too many classes/objects. Step by Step 1. Prompt the user for the amount of purchase. Must be less than 50.00 2. Read the amount of purchase and store it in a double or float. You can't just read from the keyboard any old way in Java like you can in C, for instance. Try adding this library to your sketch as demonstrated here: 3. Prompt the user for the amount he or she is paying. Probably just static text in the box above. 4. The amount paid must be less than 50.00 and greater than or equal to the amount of purchase. 5. Perform the change-making algorithm (or your own variation of it) as described under Getting Started above. 6. Output the number of each denomination you're issuing in change. In our example, you might print something like: “0 twenties”, “0 tens”, “0 fives”, “4 ones”, “2 quarters”, “1 dime”, “0 nickels” and “3 pennies”. This would show up in the text area at the bottom of the Processing window. Of course, you can probably think of a cooler graphic way to do this... Hints and Tips The best way to keep track of the value of each bill or coin denomination to facilitate a simple while loop is to initialize an array, say billsAndCoins[] with values of 20, 10, 5, 1, .25, .1, .05 and .01. Then within your loop you can determine the face value of the coin or bill you are considering giving out in change by

Subscribe to view the full document.

referring to the current element of billsAndCoins . And the currentElement is just a counter you increment each time you go around the loop. Arrays and other collection classes are covered in the text and in the links that follow Learning Objective L4,. Several other projects will use them as well.
You've reached the end of this preview.
• Spring '08
• GeraldReed
• \$5, Meyer, \$5.13

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern