• 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

I'm stuck on this problem. Need Help!! Thank you

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


a program to give customers the correct change. Here are the parameters:

1) Coins to use and their values: Half Dollars (50) Quarter Dollars (25) Dimes (10) Nickels (5) Pennies (1)

The user will enter a number between 1 and 99. If the number is outside of that range, you will inform the user and terminate the program.

You will use as few coins as possible. For example, if the user enters "50", you will give the answer as "One Half Dollar" and not "5 Dimes" or "50 Pennies".
You will loop through each coin denomination, with the possible exception of the penny. Here is a hint:
If the number is 99, then subtract 50 from the number using a loop. This leaves 49, with one half dollar used.
Next, subtract 25 from the total using a loop. This leaves 24, with one quarter used
Next, subtract 10 cents from the total in a loop. This will leave 4 cents, with two dimes used.
Finally record the four pennies left over.
The output should read something like: "You have one half dollar, one quarter, two dimes, and four pennies".
 
Saloon Keeper
Posts: 7585
176
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That sounds like homework you're supposed to be doing in order to learn something. So: what do you have so far, and where are you stuck making progress? If you haven't started, what ideas have you had?
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please search this website; somebody else asked a similar question less than a week ago.
reply
    Bookmark Topic Watch Topic
  • New Topic