Jus S

11-21-2008, 02:15 AM

I need to write a program for an automatic teller machine that dispenses money. The user should enter the desired amount (multiples of 10 dollars) and teh machine dispenses that amount using the least number of bills. The bills dispensed are 50s, 20s, and 10s. I also need to specify how many of each kind of bill to dispense. My mess of a code is attached. Help

#include <stdio.h>

#include <math.h>

int GetBills(int dollars, int* fifties, int* twenties, int* tens)

{

*fifties = dollars / 50;

*twenties = (dollars %= 50) / 20;

*tens = (dollars %= 20) / 10;

return *fifties || *twenties || *tens;

}

void PrintBills(int dollars, int fifties, int twenties, int tens)

{

printf("\nDispensing %d dollars ...", dollars)

if (fifties)

printf("\n%d $50 bills", fifties);

if (twenties)

printf("\n%d $20 bills", twenties);

if (tens)

printf("\n%d $10 bills", tens);

}

#include <stdio.h>

#include <math.h>

int GetBills(int dollars, int* fifties, int* twenties, int* tens)

{

*fifties = dollars / 50;

*twenties = (dollars %= 50) / 20;

*tens = (dollars %= 20) / 10;

return *fifties || *twenties || *tens;

}

void PrintBills(int dollars, int fifties, int twenties, int tens)

{

printf("\nDispensing %d dollars ...", dollars)

if (fifties)

printf("\n%d $50 bills", fifties);

if (twenties)

printf("\n%d $20 bills", twenties);

if (tens)

printf("\n%d $10 bills", tens);

}