Help with my program..

This is a discussion on Help with my program.. within the C Programming forums, part of the General Programming Boards category; I'm currently working on a program that will ask the user of an amount of money as the input and ...

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    2

    Help with my program..

    I'm currently working on a program that will ask the user of an amount of money as the input and the program will tell what kind and how many bill and/or coin will be used to form that amount of money. The denominations used are 1000 bill, 500 bill, 200 bill, 100 bill, 50 bill, 20 bill, 10 coin, 5 coin, 1 coin, 25 cents coin, 10 cents coin, 5 cents coin and 1 cent coin.
    I have no problems from 1000 bill down to 1 coin but having trouble when I'm already working with the cents. Any tips?

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Why are cents any different?

  3. #3
    Registered User
    Join Date
    Sep 2009
    Posts
    2
    Quote Originally Posted by tabstop View Post
    Why are cents any different?
    Because instead of an integer it will already be a float value. What will I do?


    Code:
    #include <stdio.h>
    
    int main()
    {
    int money, a, b, c;
    
    printf("Enter an amount:");
    scanf("%d", &money);
    
    if (money >= 1000)
    {
     a = money / 1000;
     b =money % 1000;
    printf("%d - One thousand peso bill", a);
    
    if (b != 0)
          {
           a = b / 500;
           c = b % 500;
           printf("%d - Five hundred peso bill", a);
           }
     ........and so on..
    }
    
    }
    Is there any other way to do it? Tips please

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,144
    Quote Originally Posted by madeyoulook
    Because instead of an integer it will already be a float value. What will I do?
    Do the calculations using cents instead of dollars so you only work with integers.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

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