Question

Must be done in C This C Program performs ATM transaction. The type of ATM transaction...

Must be done in C

This C Program performs ATM transaction. The type of ATM transaction is:

Cash withdrawal

Cash available to withdraw $2540

$2540 will be withdrawn.

Will be withdrawn in bills of:

$1000 (Two $1000 bills)

$500 (One $500 bill)

$20 (One $20 bill)

$10 (One $10 bill)

$5 (One $5 bill)

$2 (Two $2 bill)

$1 (One $1 bill)

Show steps with comments. Make it simple and nothing complicated please.

Homework Answers

Answer #1

Please find below code and don't forget to give a Like.


#include <stdio.h>

int main()
{   
int totalcash=2540,temp; /* created a integer total cash for 2540 */
/* Since we need change so we created change of size 7 which is array */
int cashchange[7]={1000,500,20,10,5,2,1};
/* we need to show the count of cash that is required */
int count[7]={0,0,0,0,0,0,0};
int i=0;
temp=totalcash;
/* this should check all the coins so while loop*/
while(i<=6){
/* checking whether every change is lessthan or equal to total cash if so we reduce that change from total */
if(cashchange[i]<=totalcash){
totalcash=totalcash-cashchange[i];
/* making count of that particular coin */
count[i]=count[i]+1;
}
/* since repetition of that coin is allowed so we take increment(to go to next coin) in else loop */
else{
i++;
}
}
printf("Cash withdrawal\n");
printf("Cash availble to withdrawn $%d",temp);
printf("\n$%d will be withdrawn\n",temp);
printf("Will be withdrawn in the bills of:\n");
/* to print all the coins we use for loop which rotates all the elements */
for(int j=0;j<=6;j++){
if(count[i]!=0){
printf("$%d(%d $%d bills)",cashchange[j],count[j],cashchange[j]);
printf("\n");
}
  
}
return 0;
}

Output will be:

Cash withdrawal
Cash availble to withdrawn $2540
$2540 will be withdrawn
Will be withdrawn in the bills of:
$1000(2 $1000 bills)
$500(1 $500 bills)
$20(2 $20 bills)
$10(0 $10 bills)
$5(0 $5 bills)
$2(0 $2 bills)
$1(0 $1 bills)

Since 40 totalcash is available so it will take 2 20s to complete the task instead of 1.

$2 (Two $2 bill) - here you mentioned two $2... If there is 40 cash then system will prefer two $20s than going to $10 when we compare with your example then code should work perfectly.

Know the answer?
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
Similar Questions
For Java For this assignment you will develop two classes called ATM and Customer that simulate...
For Java For this assignment you will develop two classes called ATM and Customer that simulate an imaginary automated teller machine (ATM). In the assignment, you should also develop a UML class diagram for the ATM class and a jUnit test case. In the program, we assume that an ATM initially keeps $100.00 cash for customer transactions. Additionally, we assume that there are a total of ten customers combined for the Union Bank and BOA banks. This is a list...
Complete this in C++ and explain what is being done. 1      Introduction The functions in the...
Complete this in C++ and explain what is being done. 1      Introduction The functions in the following subsections can all go in one big file called pointerpractice.cpp. 1.1     Basics Write a function, int square 1(int∗ p), that takes a pointer to an int and returns the square of the int that it points to. Write a function, void square 2(int∗ p), that takes a pointer to an int and replaces that int (the one pointed to by p) with its...
Brandon Lang is a creative entrepreneur who has developed a novelty soap item called Jackpot to...
Brandon Lang is a creative entrepreneur who has developed a novelty soap item called Jackpot to target consumers with a gambling habit. Inside each bar of Jackpot shower soap is a single rolled-up bill of U.S. currency. The currency (rolled up and sealed in shrinkwrap) is appropriately inserted into the soap mixture prior to the cutting and stamping procedure. The distribution of paper currency (per 1000 bars of soap) is given in the following table. Distribution of Paper Currency Prizes...
Use excel Add a column called “sale type” which describes how profitable the sale was. It...
Use excel Add a column called “sale type” which describes how profitable the sale was. It has to show one of the following values: •   Good, if either the sale quantity is larger than 12, or the product unit price is more than $15, or the total profit is more than $90 •   Bad, if the product price is less than $10 and the quantity is less than 5, or if the total sale value is less than $80 and...
Calculations must be done in Excel - Using the capital budgeting method of; Tax Effects, then...
Calculations must be done in Excel - Using the capital budgeting method of; Tax Effects, then Cash flows, then NPV. As the financial advisor to All Star Manufacturing you are evaluating the following new investment in a manufacturing project: - The project has a useful life of 12 years. Land costs $6m and is estimated to have a resale value of $10m at the completion of the project. Buildings cost $5m, with allowable depreciation of 10% pa reducing balance and...
DRT Bank has 10 automatic teller machines (ATM) spread throughout the city maintained by the ATM...
DRT Bank has 10 automatic teller machines (ATM) spread throughout the city maintained by the ATM Department. You have been assigned the task of determining the cost of operating each machine. Management will use the information you develop to evaluate the desirability of continuing to operate each machine and/or changing security arrangements for a particular machine. The ATM Department consist of a total of six employees: a supervisor, a head cashier, two associate cashiers, and two maintenance personnel. The associate...
Complete the journal entries for each of the transactions. Transaction Description of transaction 01. June 1:...
Complete the journal entries for each of the transactions. Transaction Description of transaction 01. June 1: Byte of Accounting, Inc. issued 2,580 shares of its common stock to Jeremy after $25,200 in cash and computer equipment with a fair market value of $36,720 were received. 02. June 1: Byte of Accounting, Inc. issued 2,488 shares of its common stock after acquiring from Courtney $46,800 in cash, computer equipment with a fair market value of $12,000 and office equipment with a...
How much money do you think you would earn in a period of 30 days if...
How much money do you think you would earn in a period of 30 days if you were paid as follows: one cent for the first day, two cents for the second day, four cents for the third day, eight cents for the fourth day, and so on (i.e. your salary doubles each day)? Do you think you would make very little money, just a few dollars, at the end of the 30-day period? Let us write a program to...
Objective: Write a Java program that will use a JComboBox from which the user will select...
Objective: Write a Java program that will use a JComboBox from which the user will select to convert a temperature from either Celsius to Fahrenheit, or Fahrenheit to Celsius. The user will enter a temperature in a text field from which the conversion calculation will be made. The converted temperature will be displayed in an uneditable text field with an appropriate label. Specifications Structure your file name and class name on the following pattern: The first three letters of your...
prepare general journal for the following Transaction Date Description 1 July 1 Began her business by...
prepare general journal for the following Transaction Date Description 1 July 1 Began her business by contributing a computer valued at $500 and rug cleaner at $6,200 and depositing $2X,XXX (XXXX- represents 0000) in a checking account in the name of the corporation in exchange for 6,000 shares, $1 par value shares of capital stock. 2 1 Received $10,000 proceeds from an unsecured, 11%, 5 year, interest only bank loan, due July 1, 2017. The proceeds will be used to...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT