write a program for an automatic teller machine that dispens

write a program for an automatic teller machine that dispenses money. the user should enter the amount of desired (a multiple of 10 dollars) and the machine dispenses this amount using the last number of billes. the bills dispensed are 50\'s, 20s, and 10s. write a function that determines how many of each kind of bill to dispense

Solution

#include <stdio.h>

float     amount;

int        fifties, twenties, tens, fives, ones;

float     cents;

int *fiftyDollarBills,*twentyDollarBills,*tenDollarBills,*fiveDollarBills,*oneDollarBills;

void inputAmount();

void parseBills(float);

void displayTotals(float);

void myMain();

int main(int argc, const char *argv[])

{

fiftyDollarBills = &fifties;

twentyDollarBills = &twenties;

tenDollarBills   = &tens;

fiveDollarBills = &fives;

oneDollarBills = &ones;

myMain();

return 0;

}

void myMain()

{

amount            = 0;

fifties               = 0;

twenties          = 0;

tens                 = 0;

fives                 = 0;

ones                 = 0;

cents                = 0;

// printf(\"PLease...\");

// scanf(\"%f\",&amount);

// printf(\"amount %f\",amount);

inputAmount();

}

void inputAmount()

{

printf(\"Please enter amount to be dispensed --> \");

scanf(\"%f\", &amount);

// printf(\"amount %.2f\ \",amount);

parseBills(amount);

}

void parseBills(float a)

{

// printf(\"parseBills\ \");

// printf(\"%.2f\ \",a);

if (a / 50 >= 1) {

*fiftyDollarBills = a / 50;

//printf(\"fifties = %i\ \", fifties);

a = a - (*fiftyDollarBills * 50);

//printf(\"%f\ \", a);

}

if (a / 20 >= 1) {

*twentyDollarBills = a / 20;

//printf(\"twenties = %i\ \", twenties);

a = a - (*twentyDollarBills * 20);

//printf(\"%f\ \", a);

}

if (a / 10 >= 1) {

*tenDollarBills = a / 10;

//printf(\"tens = %i\ \", tens);

a = a - (*tenDollarBills * 10);

//printf(\"%f\ \", a);

}

if (a / 5 >= 1) {

*fiftyDollarBills = a / 5;

//printf(\"fives = %i\ \", fives);

a = a - (*fiftyDollarBills * 5);

//printf(\"%f\ \", a);

}

if (a / 1 >= 1) {

*oneDollarBills = a / 1;

//printf(\"ones = %i\ \", ones);

a = a - (*oneDollarBills * 1);

//printf(\"%f\ \", a);

}

displayTotals(a);

}

void displayTotals(float a){

//printf(\"%.2lf\",a);

printf(\"\ $%.2lf is dispensed in the following denominations:\ %i - Fifties\ %i - Twenties\ %i - Tens\ %i - Fives\ %i - Ones\ and %.2lf cents\ \",amount,*fiftyDollarBills,*twentyDollarBills,*tenDollarBills,*fiveDollarBills,*oneDollarBills,a);

}

write a program for an automatic teller machine that dispenses money. the user should enter the amount of desired (a multiple of 10 dollars) and the machine dis
write a program for an automatic teller machine that dispenses money. the user should enter the amount of desired (a multiple of 10 dollars) and the machine dis
write a program for an automatic teller machine that dispenses money. the user should enter the amount of desired (a multiple of 10 dollars) and the machine dis

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site