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");
}
-------------------------------------------------------------------------------------------------------------------------------------------------------------
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:

Write a complete C program for an automatic teller machine that dispenses money. The user should...
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...
C program help: Write a C program that uses three functions to perform the following tasks: – The first function should read the price of an item sold at a grocery store together with the quantity from the user and return all the values to main(). example: #include void getInput(int *pNum1, int *pNum2); // note: *pNum1 & *pNum2 are pointers to ints int main () { int numDucks,numCats; getInput(&numDucks, &numCats); // passing addresses of num1 & num2 to...
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...
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" <<...
Write a C program that does the following: Displays a menu (similar to what you see in a Bank ATM machine) that prompts the user to enter a single character S or D or Q and then prints a shape of Square,Diamond (with selected height and selected symbol), or Quits if user entered Q.Apart from these 2 other shapes, add a new shape of your choice for any related character. Program then prompts the user to enter a number and...
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 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...
modify the program pls so it then asks the user for another input making the program ask for a yes or no question looping it codeblocks #include <stdio.h> #include <ctype.h> #define NEWLINE '\n' int main(void) { /* Declare variables and function prototypes. */ int k=0, formula[20], n, current=0, done=0, d1, d2; double error=0, weight, total=0; double atomic_wt(int atom); /* Read chemical formula from keyboard. */ printf("Enter chemical formula for amino acid: \n"); while ((formula[k]=getchar()) != NEWLINE) k++; n = k; ...
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; }
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...