Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Cash Register  RSS feed

 
Adam Boom
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone, new guy at java here. I have to make a cash register that prompts for prices of items, prompts for coupons, outputs number of items, number of coupons, money saved, subtotal, tax %, tax in $, and total. I also have to prompt for money received from customer, then break that money received down into $20's, $10's, $5's, $1's, $.25's, $.10's, $.05's, and $.01. I pretty much have all that done. It may not be the best program in the world, but hey, I'm new. My problem is at the very end of the program, when I have to output the CHANGE DUE to the customer. It has to be broken down like I said earlier into 20's, 10's, etc.. and only show relevant bills. So if the total is $9, customer gives $10, only $1 change should show under CHANGE DUE. Instead I'm getting all the bills with 0's next to them, and a 1 next to the actual $1.

Here is what the final output looks like for change due

------ *** CHANGE DUE *** ------
$20.00 - 0
$10.00 - 0
$5.00  - 0
$1.00  - 4
$0.25  - 2
$0.10  - 1
$0.05  - 0
$0.01  - 1

I need the ones with 0's to not showup in the console but I can't seem to figure it out. Here is my entire code
 
Norm Radder
Ranch Foreman
Posts: 2240
28
 
Adam Boom
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Ok? Thanks I guess. Not sure what that has to do with anything. Someone here might have different insight.
 
Knute Snortum
Sheriff
Posts: 4073
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cross posting is generally considered bad form.  It means that someone here might work on an answer when you already have a solution in the other forum.

At JavaRanch, cross-posting is allowed only if you are upfront about it.  Norm's post alerts members to the fact that you have cross-posted.

I used the link to look at the other forum post and I saw that you had a perfectly good answer there, so I didn't bother taking a hard look at your code.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!