This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

Andres
Andres presents ...

2010/6/28

AP Computer Science Summer Assignment

"Write a program to simulate a cash register change calculator. Allow the user to
enter a purchase price of up to 100 dollars. Then determine the best change to
give back for a $100 bill. Print the results to the screen as below, with no zero
results displayed. Note: ignore the existence of half-dollars, $2 bills and $50 bills.
Assume that the purchase price is a whole amount. "


This was kind of annoying to make. But I am proud of it. You should be too.
I used Ninto's bitfont class.

CONTROLS:

Click "TENDERED" and enter the amount of money you're "paying". Backspace to clear.

Click "ITEM PRICE" and enter the price of the item you're "paying for". Backspace to clear.

Click the "CHANGE:" block to calculate the best change combination of $1, $5, $10, and $20.

UPDATE: Fixed it so numbers higher than 100 can't be entered. (see rules ^ )
UPDATE: Made the default "tendered" $100. Can still be changed to any number <= 100, but the instructions say the person is paying with $100.
UPDATE: Fixed it so it resets the "results" arraylist when you click to calculate the change combination... before it would just add the number of bills from the new calculation to the results from the last one and display the sums.... doh
...and finally commented.

2847 views / 7 in the last 7 days

Tags: simulation awesome with-source

open in greenfoot
Your browser does not support the canvas tag.
A new version of this scenario was uploaded on Mon Jun 28 01:55:01 UTC 2010
A new version of this scenario was uploaded on Mon Jun 28 14:09:06 UTC 2010
A new version of this scenario was uploaded on Mon Jun 28 14:11:55 UTC 2010
A new version of this scenario was uploaded on Mon Jun 28 15:23:07 UTC 2010
A new version of this scenario was uploaded on Mon Jun 28 15:34:32 UTC 2010
A new version of this scenario was uploaded on Mon Jun 28 17:03:19 UTC 2010
A new version of this scenario was uploaded on Mon Jun 28 17:04:28 UTC 2010
A new version of this scenario was uploaded on Mon Jun 28 17:08:25 UTC 2010
AndresAndres

2010/6/28

This might be cool for other people to try... just to see different interesting solutions.
A new version of this scenario was uploaded on Mon Aug 09 01:21:04 UTC 2010

See all comments

Want to leave a comment? You must first log in.

Who likes this?

No votes yet.