• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cash Register

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also posted at: http://www.dreamincode.net/forums/topic/397188-cash-register-problems/
 
Adam Boom
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Norm Radder wrote:Also posted at: http://www.dreamincode.net/forums/topic/397188-cash-register-problems/



Ok? Thanks I guess. Not sure what that has to do with anything. Someone here might have different insight.
 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic