Question

Write a complete C program for an automatic teller machine that dispenses money. The user should...

Write a complete C program for an automatic teller machine that dispenses money. The user should enter the amount desired (a multiple of 10 dollars) and the machine dispenses this amount using the least number of bills. The bills dispenses are 50s, 20s, and 10s. Write a function that determines how many of each kind of bill to dispense.

When writing your function begin to pass your variables using pointers (or rather "pointing" to your data". Use the TimeSpace program example attached as you need to.

TimeSpace program example

-------------------------------------------------------------------------------------------------------------------------------------------------------------

#include <stdio.h>

void timer(int,int *,int *,int *); // * pointer, capable of holding an address
void print_results(int,int,int,int);
void explanation();

int main()
{
   int total_secs,hours,minutes,seconds;
  
   explanation();
  
   printf("How may total seconds to convert?\n");
   scanf("%d",&total_secs);
  
   timer(total_secs,&hours,&minutes,&seconds);//& indicates address of
  
   print_results(total_secs,hours,minutes,seconds);
      
   return 0;
}

void print_results(int ts, int h, int m, int s)
{
   printf("Total Seconds Entered: %8d\n",ts);
   printf("Hours : %8d\n",h);
   printf("Minutes : %8d\n",m);
   printf("Seconds : %8d\n",s);
}


void timer(int ts,int *h,int *m, int *s)//* indicates a variable than hold an address
{
   *h=ts/3600;
   ts=ts%3600;
   *m=ts/60;
   ts=ts%60;
   *s=ts;
}


void explanation()
{
   printf("Give me a total number of seconds\n");
   printf("and I will tell you how many \n");
   printf("hours, minutes, and seconds it is.\n\n");
}

-------------------------------------------------------------------------------------------------------------------------------------------------------------

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution:

#include<stdio.h>
void main()
{

   int fifties=0,twenties=0,tens=0;
   int amount;
   void calculateLeastBills(int*,int*,int*,int*);

   printf("Enter your Amount:");
   scanf("%d",&amount);
  
   calculateLeastBills(&amount,&fifties,&twenties,&tens);
  
   printf("\nThe number of fifties dispensed:%d\n",fifties);
   printf("The number of twenties dispensed:%d\n",twenties);
   printf("The number of tens dispensed:%d\n",tens);
}
void calculateLeastBills(int *am,int *fi,int *tw,int *te)
{
  
   while(*am>0)
   {
       if(*am>=50)
       {
           *fi=*am/50;
           *am=*am-((*fi)*50);
       }
       else if(*am>=20)
       {
           *tw=*am/20;
           *am=*am-((*tw)*20);
       }
       else if(*am>=10)
       {
           *te=*am/10;
           *am=*am-((*te)*10);
       }
   }
}

Output:

Add a comment
Know the answer?
Add Answer to:
Write a complete C program for an automatic teller machine that dispenses money. The user should...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I'm having trouble understanding pointers in my c programming class. I posted the pointer assignment below....

    I'm having trouble understanding pointers in my c programming class. I posted the pointer assignment below. If you could leave comments pointing out where pointers are used it would be much appreciated! ----------------------------------------------------------------------------------------------------------------------------------- Write a complete C program for an automatic teller machine that dispenses money. The user should enter the amount desired (a multiple of 10 dollars) and the machine dispenses this amount using the least number of bills. The bills dispenses are 50s, 20s, and 10s. Write a...

  • Write a Java program for a fortune teller. The program should begin by asking the user...

    Write a Java program for a fortune teller. The program should begin by asking the user to enter their name. Following that the program will display a greeting. Next, the program will ask the user to enter the month (a number 1-12) and day of the month (a number 1-13) they were born. Following that the program will display their zodiac sign. Next, the program will ask the user their favorites color (the only choices should be: red, green and...

  • I have a program that needs comments added to it: #include <iostream> #include <stdio.h> #include <conio.h>...

    I have a program that needs comments added to it: #include <iostream> #include <stdio.h> #include <conio.h> #include <windows.h> using namespace std; int main() { int m, s,h; cout << "A COUNTDOWN TIMER " << endl; cout << "enter time in hours here" << endl; cin >> h; cout << "enter time in minutes here " << endl; cin >> m; cout << "enter time in seconds here" << endl; cin >> s; cout << "Press any key to start" <<...

  • This is done in c programming and i have the code for the programs that it wants at the bottom i ...

    This is done in c programming and i have the code for the programs that it wants at the bottom i jut dont know how to call the functions Program 2:Tip,Tax,Total int main(void) {    // Constant and Variable Declarations    double costTotal= 0;    double taxTotal = 0;    double totalBill = 0;    double tipPercent = 0;    // *** Your program goes here ***    printf("Enter amount of the bill: $");    scanf("%lf", &costTotal);    printf("\n");    // *** processing ***    taxTotal = 0.07 * costTotal;    totalBill...

  • Write a complete C program that inputs a paragraph of text and prints out each unique...

    Write a complete C program that inputs a paragraph of text and prints out each unique letter found in the text along with the number of times it occurred. A sample run of the program is given below. You should input your text from a data file specified on the command line. Your output should be formatted and presented exactly like the sample run (i.e. alphabetized with the exact spacings and output labels). The name of your data file along...

  • C Programming - RSA Encryption I've tried to write a program that can encrypt and decrypt...

    C Programming - RSA Encryption I've tried to write a program that can encrypt and decrypt strings using RSA and want to be able to integrate it into a header file which contains codes for compression, linked list etc.. However, the use of global variables and fixed size of encryption is making it hard to do so Can someone please help me modify the following the code? I want to be able to just pass it in a string to...

  • C Programming - RSA Encryption I've tried to write a program that can encrypt and decrypt strings using RSA and want...

    C Programming - RSA Encryption I've tried to write a program that can encrypt and decrypt strings using RSA and want to be able to integrate it into a header file which contains codes for compression, linked list etc.. However, the use of global variables and fixed size of encryption is making it hard to do so Can someone please help me modify the following the code? I want to be able to just pass it in a string to...

  • I am trying to write a short program in C that prints the letters that are...

    I am trying to write a short program in C that prints the letters that are the same in two different arrays. I am getting a error. #include <stdio.h> int main() {           char first[7]={'y','a','s','m','i','n','e'};        char last[5]={'s','m','i','t','h'};        int i;                        while(first[i] != '\0') && (last[i] != '\0')        {            if(first[i]==last[i])                 printf("%s", first[i]);                  }         return 0;          }

  • This is a c++ program. Use the description from Parking Ticket Simulator (listed below) as a basis, where you need to...

    This is a c++ program. Use the description from Parking Ticket Simulator (listed below) as a basis, where you need to create a Car class and Police Officer class, to create a new simulation. Write a simulation program (refer to the Bank Teller example listed below) that simulates cars entering a parking lot, paying for parking, and leaving the parking lot. The officer will randomly appear to survey the cars in the lot to ensure that no cars are parked...

  • 1. (50 pts) Write a C or C++ program A6p1.c(pp) that accepts one command line argument which is an integer...

    1. (50 pts) Write a C or C++ program A6p1.c(pp) that accepts one command line argument which is an integer n between 2 and 6 inclusive. Generate a string of 60 random upper case English characters and store them somewhere (e.g. in a char array). Use pthread to create n threads to convert the string into a complementary string ('A'<>'Z', 'B'<->'Y', 'C''X', etc). You should divide this conversion task among the n threads as evenly as possible, Print out the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT