Thread: Help! confused on how to run this program about money

  1. #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("&#37;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

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    1898 / 1000 = 1 <-- this is your first answer
    1898 &#37; 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.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help on making program run more efficiently
    By peeweearies in forum C Programming
    Replies: 2
    Last Post: 03-23-2009, 02:01 AM
  2. Help me with my basic program, nothing I create will run
    By Ravens'sWrath in forum C Programming
    Replies: 31
    Last Post: 05-13-2007, 02:35 AM
  3. Replies: 2
    Last Post: 12-22-2006, 08:45 PM
  4. Replies: 3
    Last Post: 07-11-2005, 03:07 AM
  5. program won't run standalone
    By richard in forum C++ Programming
    Replies: 2
    Last Post: 07-20-2002, 06:21 PM

Tags for this Thread