ATM money count

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jan 2009
Posts: 7
Reputation: akim_atl is an unknown quantity at this point 
Solved Threads: 0
akim_atl akim_atl is offline Offline
Newbie Poster

ATM money count

 
0
  #1
Jan 23rd, 2009
I am all confused, I don't where to start. This is my first programming class and i need some help please.


Write a C program for an automatic teller machine that dispenses money. The user should enter the amount desired (a multiple of 10 dollars) and the machine dispenses this amount using the least number of bills. The bills dispensed are 50s, 20s, and 10s. Write a function that determines how many of each kind of bill to dispense.
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 2,035
Reputation: Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of 
Solved Threads: 177
Aia's Avatar
Aia Aia is offline Offline
Postaholic

Re: ATM money count

 
0
  #2
Jan 23rd, 2009
>I am all confused, I don't where to start.

Declare a variable that will keep money amount.
Ask the user for money amount.
Read the input.
Process the input in a function to determined how many bills of each class needs to be outputted.
Last edited by Aia; Jan 23rd, 2009 at 12:04 pm.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,752
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 740
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: ATM money count

 
1
  #3
Jan 23rd, 2009
>I am all confused, I don't where to start.
Somewhere, anywhere, even if it's completely wrong. If you have to, write a hello world program and build on it. The last thing you want to do is fall into a hole of not knowing what to do and being afraid to try something.

As a start, write just the I/O. Snip hard parts off of the program requirements until you have something workable to get you started, for example:
Write a C program for an automatic teller machine that dispenses money. The user should enter the amount desired (a multiple of 10 dollars) and the machine dispenses this amount.
This is very simple. All you're doing is taking input and spitting it back out as output. From there you can incrementally add features as you become more comfortable with the program.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 7
Reputation: akim_atl is an unknown quantity at this point 
Solved Threads: 0
akim_atl akim_atl is offline Offline
Newbie Poster

Re: ATM money count

 
0
  #4
Jan 23rd, 2009
Is this how the program should begin? i am really lost here
  1. /*
  2. * Compute the user transactions.
  3. */
  4.  
  5. #include <stdio.h>
  6.  
  7. int
  8. main (void)
  9. {
  10. double amount;
  11. double count_amount ;
  12. count_amount = 0.0;
  13. while (count_amount < amount) {
  14. printf("Enter the amount to withdraw >");
  15. scanf("%1f", &count_amount);
  16.  
  17. count_amount = count_amount + 10;
  18.  
  19. return
  20.  
  21. }
  22. count_amount = count_amount + 10
Last edited by Narue; Jan 23rd, 2009 at 5:42 pm. Reason: added code tags
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 584
Reputation: Murtan is a jewel in the rough Murtan is a jewel in the rough Murtan is a jewel in the rough Murtan is a jewel in the rough 
Solved Threads: 94
Murtan Murtan is online now Online
Posting Pro

Re: ATM money count

 
0
  #5
Jan 24th, 2009
How would you solve the problem manually?

I want to withdraw $180, what bills would you give me?

How did you decide how many to give me?

Ok now make the computer do it...

Write some code that asks how much to withdraw.
Add a print statement that outputs what it thought I entered.
(The last step might be temporary, but its always nice to verify the input works.)
Then write some code to have the computer follow the way you solved the problem by hand.
Add some code to output what you calculated.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 90
Reputation: ajay.krish123 is an unknown quantity at this point 
Solved Threads: 8
ajay.krish123 ajay.krish123 is offline Offline
Junior Poster in Training

Re: ATM money count

 
0
  #6
Jan 24th, 2009
>I am all confused, I don't where to start. This is my first programming class and i need some help please.
Before writing the code you must make the algorithm of the program you require which includes writing the steps for solving a particular problem.This will help you while writing the code.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 7
Reputation: akim_atl is an unknown quantity at this point 
Solved Threads: 0
akim_atl akim_atl is offline Offline
Newbie Poster

Re: ATM money count

 
0
  #7
Jan 25th, 2009
Originally Posted by Aia View Post
>I am all confused, I don't where to start.

Declare a variable that will keep money amount.
Ask the user for money amount.
Read the input.
Process the input in a function to determined how many bills of each class needs to be outputted.
  1. /*
  2. * Compute the user transactions.
  3. */
  4.  
  5. #include <stdio.h>
  6.  
  7. int
  8. main (void)
  9. {
  10. int amount;
  11. int number_bills;
  12.  
  13. printf("Enter the amount to withdraw >");
  14. scanf("%d", &amount);
  15.  
  16. number_bills=0;
  17. while (amount >= 50) {
  18. number_bills++;
  19. amount -= 50;
  20. }
  21.  
  22. printf("Dispense %d $50 bill(s), ",number_bills);
  23.  
  24. number_bills=0;
  25. while (amount >= 20) {
  26. number_bills++;
  27. amount -= 20;
  28. }
  29.  
  30. printf("%d $20 bill(s), ",number_bills);
  31.  
  32. number_bills=0;
  33. while (amount >= 10) {
  34. number_bills++;
  35. amount -= 10;
  36. }
  37.  
  38. printf("and %d $10 bill(s).\n",number_bills);
  39.  
  40. return 0;
  41. }
Last edited by Narue; Jan 25th, 2009 at 9:03 am. Reason: added code tags, but no formatting to begin with
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 2,035
Reputation: Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of 
Solved Threads: 177
Aia's Avatar
Aia Aia is offline Offline
Postaholic

Re: ATM money count

 
0
  #8
Jan 25th, 2009
>Write a function that determines how many of each kind of bill to dispense.
What about this part now? Can you take the processing of bills away from main and implement it in a function?

Use code tags to preserver the indentation and format of your code. How? Highlight all your source code, then click the # at the top of the message window. Add a '=c' to the beginning tag like: [CODE=C] to specify that we are dealing with the C language.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC