Write a program for an automatic teller machine that dispensesmoney. The user sh
ID: 3618888 • Letter: W
Question
Write a program for an automatic teller machine that dispensesmoney. The user should enter the amount desired (a multiples of 10dollars) and the machine dispenses this amount using the leastnumber of bills. The bills dispensed are 50s, 20s, and 10s.Write a function that determines how many of each kind of bill todispense. You need to include thefollowing functions in the main as part of your solution. You mayadd other functions as you may see fit.int main (void){
/* declare the necessary variables */
loop { /* use any loop exit condition */
get_data(&amount);
/*Enter the desired amount. If the amount is incorrect(not a
multiple of 10 ) give the user several opportunitiesto re-
enter the amount */
fifties_twenties_tens(amount,&fifties,&twenties,&tens);
/*Divide the amount into number of 50’s,20’s and 10’s.*/
print(amount, fifties, twenties,tens);
/*Print the amount and the number of 50’s,20’s and
10’s */
}
return(0);
} *You need to use the % operator in get_data to determine whether theamount is a multiple of 10 and to separate the amount into fifties,twenties and tens in fifties_twenties_tensfunction. Sample output
Enter how much cash do you need? $55
This machine dispenses ONLY $50, $20, $10...
Please enter again $50
The amount you are withdrawing = $ 50
*** Take your Cash as $$$ bills ***
1 fifty 0 twenties and 0 tens
Do you want another transaction (y/n)? y
Enter how much cash do you need? $80
The amount you are withdrawing = $ 80
*** Take your Cash as $$$ bills ***
1 fifty 1 twenties and 1 tens
Do you want another transaction (y/n)? n Write a program for an automatic teller machine that dispensesmoney. The user should enter the amount desired (a multiples of 10dollars) and the machine dispenses this amount using the leastnumber of bills. The bills dispensed are 50s, 20s, and 10s.Write a function that determines how many of each kind of bill todispense. You need to include thefollowing functions in the main as part of your solution. You mayadd other functions as you may see fit.
int main (void){
/* declare the necessary variables */
loop { /* use any loop exit condition */
get_data(&amount);
/*Enter the desired amount. If the amount is incorrect(not a
multiple of 10 ) give the user several opportunitiesto re-
enter the amount */
fifties_twenties_tens(amount,&fifties,&twenties,&tens);
/*Divide the amount into number of 50’s,20’s and 10’s.*/
print(amount, fifties, twenties,tens);
/*Print the amount and the number of 50’s,20’s and
10’s */
}
return(0);
} *You need to use the % operator in get_data to determine whether theamount is a multiple of 10 and to separate the amount into fifties,twenties and tens in fifties_twenties_tensfunction. Sample output
Enter how much cash do you need? $55
This machine dispenses ONLY $50, $20, $10...
Please enter again $50
The amount you are withdrawing = $ 50
*** Take your Cash as $$$ bills ***
1 fifty 0 twenties and 0 tens
Do you want another transaction (y/n)? y
Enter how much cash do you need? $80
The amount you are withdrawing = $ 80
*** Take your Cash as $$$ bills ***
1 fifty 1 twenties and 1 tens
Do you want another transaction (y/n)? n
Explanation / Answer
please rate - thanks #include #include void get_data(int*); void fifties_twenties_tens(int,int*,int*,int*); void print(int,int,int,int); int main (void){ /* declare the necessary variables */ int amount,fifties,twenties,tens; char choice='y'; while(choice=='y'||choice=='Y') { /* use any loop exit condition */ get_data(&amount); /*Enter the desired amount. If the amount is incorrect (nota multiple of 10 ) give the user several opportunitiesto re- enter the amount */ fifties_twenties_tens(amount,&fifties,&twenties,&tens); /*Divide the amount into number of 50’s,20’s and 10’s.*/ print(amount, fifties, twenties, tens); /*Print the amount and the number of 50’s,20’s and 10’s */ while (getchar() != ' ' ); printf("Do you want another transaction (y/n)? "); scanf("%c",&choice); } return(0); } void get_data(int* n) {printf("Enter how much cash do you need? $"); scanf("%d",n); while(*n%10!=0) {printf("This machine dispenses ONLY $50, $20,$10... "); printf("Please enter again $"); scanf("%d",n); } } void fifties_twenties_tens(int n,int* fifty,int* twenty,int*ten) {*fifty=n/50; n%=50; *twenty=n/20; *ten=n%20; } void print(int n,int fifty,int twenty,int ten) {printf("The amount you are withdrawing = $%d ",n); printf("*** Take your Cash as $$$ bills *** "); printf("%d fifty %d twenties and %dtens ",fifty,twenty,ten); }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.