![]() |
| | #1 |
| Registered User Join Date: Jun 2008
Posts: 5
| i thought of many possible things i learn't but maybe it still isn't enough... maybe you can help me finish this program with just basic variables in it.. printf, scanf, and the like... THE PROBLEM: create a program that will ask an amount in pesos(integer) and determine the lowest # of bills he will need to achieve the amount entered. The bills in use are 1000peso, 500peso, 200peso, 100peso, 50peso, 20peso, 10peso, 5peso, 1peso. /* peso is a currency XD */ an example would be if i entered an amount of 1898 pesos, it would come up with you need: peso1000:1 peso500:1 peso200:1 peso100:1 oeso50:1 peso20:2 peso10: peso5:1 peso1:3 so far i've made this: i know the nAmnt's in the printf's are wrong but i just don't know what to put. Code: #include <stdio.h>
main()
{
int nPeso1000,
nPeso500,
nPeso200,
nPeso100,
nPeso50,
nPeso20,
nCoin10,
nCoin5,
nCoin1,
n,
nAmnt;
printf("Enter Amount:");
scanf("%d", nAmnt);
printf("xxxxxxxxx\n");
printf("xxBillsxx\n");
printf("xxxxxxxxx\n\n");
printf("1000:%d\n",nAmnt);
printf("500:%d\n", nAmnt);
printf("500:%d\n", nAmnt);
printf("200:%d\n", nAmnt);
printf("100:%d\n", nAmnt);
printf("50:%d\n", nAmnt);
printf("20:%d\n\n", nAmnt);
printf("xxxxxxxxx\n");
printf("xxCoinsxx\n");
printf("xxxxxxxxx\n\n");
printf("10:%d\n", nAmnt);
printf("5:%d\n", nAmnt);
printf("1:%d\n", nAmnt);
getch();
return 0;
}
Last edited by Salem; 06-13-2008 at 10:05 PM. Reason: code tags around only the code |
| jumbo2410 is offline | |
| | #2 |
| and the hat of vanishing Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,214
| 1898 / 1000 = 1 <-- this is your first answer 1898 % 1000 = 898 <-- use this as the start for your next answer Do that all the way down through your currency values.
__________________ If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut. Up to 8Mb PlusNet broadband from only £5.99 a month! |
| Salem is offline | |
| | #3 |
| and the Hat of Guessing Join Date: Nov 2007
Posts: 8,740
| If you had to count out 1898 pesos yourself, how would you do it? Once you know how to do it, then you can carry those calculations into C. |
| tabstop is offline | |
![]() |
| Tags |
| basic, c programming, money, peso |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help on making program run more efficiently | peeweearies | C Programming | 2 | 03-23-2009 02:01 AM |
| Help me with my basic program, nothing I create will run | Ravens'sWrath | C Programming | 31 | 05-13-2007 02:35 AM |
| Need help getting a program to run command prompt and a windows app together | Crazy Glue | C# Programming | 2 | 12-22-2006 08:45 PM |
| Program with rand() func produces same results every run | benj05 | C++ Programming | 3 | 07-11-2005 03:07 AM |
| program won't run standalone | richard | C++ Programming | 2 | 07-20-2002 06:21 PM |