Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

How to start

help urgent

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1 adamcprog15

adamcprog15

    CC Regular

  • Member
  • PipPipPip
  • 27 posts

Posted 01 December 2014 - 07:25 AM

You are required to write a program to dispense change for an automatic cash register. The user will input the total amount due and the amount tendered by the customer. The program will return the amount to be returned to the customer as well as the coins needed. You will require two functions, one function calculate_change and another function dispense_change. Write function prototypes for these 2 functions.


Edited by Roger, 02 December 2014 - 07:50 AM.


#2 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts

Posted 01 December 2014 - 07:58 AM

Do you know how you would do this by hand?


Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#3 adamcprog15

adamcprog15

    CC Regular

  • Member
  • PipPipPip
  • 27 posts

Posted 02 December 2014 - 08:57 AM

no explain how



#4 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts

Posted 02 December 2014 - 09:26 AM

As an example, let's say we're dealing with US currency.

 

I have a bill of $8.73, and hand over a $20.00 bill.

 

In US currency, bill denominations will generally be $1, $5, $10, $20, $50, $100, with coin denominations of 25, 10, 5, and 1 cent. There are $2 bills and 50 and 100 cent coins, but we'll ignore them for now.

 

So, If I hand over a $20 bill, then the change due is 20-8.73 = 11.27.

The largest bill smaller than that is $10, so I'll use one of those.

That leaves 11.27 - 10 = 1.27.

I can't use a $5 bill, so I'll use $1 next. One of those.

That leaves 1.27 - 1 = 0.27, or 27 cents.

A quarter (25 cents) will bring the change due down to 2 cents.

Two pennies (1 cent) will bring the change due down to 0, and we're done.

Change back is a ten, a one, a quarter, and two pennies.


Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download