C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 06-13-2008, 10:03 PM   #1
Registered User
 
Join Date: Jun 2008
Posts: 5
Talking Help! confused on how to run this program about money

this is sort of like an atm-ish project....
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   Reply With Quote
Old 06-13-2008, 10:07 PM   #2
and the hat of vanishing
 
Salem's Avatar
 
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   Reply With Quote
Old 06-13-2008, 10:08 PM   #3
and the Hat of Guessing
 
tabstop's Avatar
 
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   Reply With Quote
Reply

Tags
basic, c programming, money, peso

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 02:51 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22