Question

In: Computer Science

In the space provided below write a C ++ program that computes the total amount of...

In the space provided below write a C ++ program that computes the total amount of money you are depositing in your bank account. Your program does this by asking you to first enter the number and amount of each check you are depositing, and then it asks you to enter the type of cash bills being deposited and how many of each type, also the types of coins being deposited, and the number of each coin type.

Solutions

Expert Solution

#include <iostream>

using namespace std;

int main()
{
//variable declaration
int numChecks;
float amount, totalAmount=0;
  
//input the number of checks
cout << "Enter the number of checks:";
cin>>numChecks;
  
//get the amount of each of the check
for(int i=0; i<numChecks; i++)
{
cout<<"Enter the amount of check "<<(i+1)<<": ";
cin>>amount;
totalAmount = totalAmount + amount;
}
  
//display the total amount
cout<<endl<<"The total amount you are depositing: "<<totalAmount;
  
return 0;
}

OUTPUT:

Enter the number of checks:4
Enter the amount of check 1: 1500
Enter the amount of check 2: 2000
Enter the amount of check 3: 2000
Enter the amount of check 4: 1500

The total amount you are depositing: 7000

OR

check out the solution.

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

CODE :

#include <iostream>

using namespace std;

int main() {
// variables declaration
int chk_number, amt, chk_amount, bills, coins, n, amount;
char choice;
// initialize variables
chk_amount = 0;
amount = 0;
  
// infinite loop till user enter 'n' or 'N'
do {
// prompt to user
cout << "\nEnter number and amount of check : ";
// read number and amount
cin >> chk_number >> amt;
// sum up all check amounts
chk_amount = chk_amount + amt;
  
// infinite loop till user no longer want to enter cash bills
while(true) {
// assuming 1000 , 100, 50 and 10 bills
cout << "\nEnter the type of cash bills (1000/100/50/10) and 0 to stop : ";
cin >> bills; // read bills
  
// if bills is not 0 then proceed further else break from the while loop
if(bills != 0) {
// enter the number of each type
cout << "Enter the number of that cash type : ";
cin >> n;
// sum up every amount
amount = amount + (bills * n);
}
else
break;
} // while ends
  
// infinite loop till user no longer want to enter coins
while(true) {
// assuming 1, 2 and 5 coins
cout << "\nEnter the type of coins (1/2/5) and 0 to stop : ";
cin >> coins; // read coins
  
// if coins is not 0 then proceed further else break from the while loop
if(coins != 0) {
// enter the number of each type
cout << "Enter the number of that coin type : ";
cin >> n;
// sum up everything
amount = amount + (coins * n);
}
else
break;
} // while ends
  
// ask user whether he has another check to deposit
cout << "\nDo you have another check to deposit (y/n) ? : ";
cin >> choice;
  
}while(choice != 'n' && choice != 'N');
  
// validate if all check amounts tally with entered cash bills and coins
// if valid then print the amount
if (chk_amount == amount) {
cout << "\n\nTotal check amount == the amount of all cash bills and coins - Valid";
cout << "\nTotal amount of money depositing is : " << amount << " units";
}
else
cout << "\nTotal check amount != the amount of all cash bills and coins - Invalid";
  
} // program ends

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

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

OUTPUT ::

1. input with 1 check deposit

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

2. input with 2 checks deposit.

===================================================

i hope it helps..

If you have any doubts please comment and please don't dislike.

PLEASE GIVE ME A LIKE. ITS VERY IMPORTANT FOR ME


Related Solutions

In the space provided below write a C program that computes the total amount of money...
In the space provided below write a C program that computes the total amount of money you have stored in your piggy bank. Your program does this by asking you for number of pennies, nickels, dimes, and quarters in the piggy bank and then displays how much money in total is in the piggy bank.
In the space provided below write a C++ program that computes the total cost of books...
In the space provided below write a C++ program that computes the total cost of books you want to order from an online bookstore. It does so by first asking how many books are in your shopping cart and then based on that number, it repeatedly asks you to enter the cost of each item. It then calls two functions: one for computing the taxes and another for computing the delivery charges. The function which computes delivery charges works as...
In the space provided below write a C program that computes the total cost of items...
In the space provided below write a C program that computes the total cost of items you want to order online. It does so by first asking how many items are in your shopping cart and then based on that number, it repeatedly asks you to enter the cost of each item. It then adds a 5% delivery charge for standard delivery if the total is below $1,000, and an additional 10% charge if you want an expedited next day...
In the space provided below write a C program that computes the total cost of items...
In the space provided below write a C program that computes the total cost of items you want to order online. It does so by first asking how many items are in your shopping cart and then based on that number, it repeatedly asks you to enter the cost of each item. It then adds a 5% delivery charge for standard delivery if the total is below $1,000, and an additional 10% charge if you want an expedited next day...
In the space provided below write a C++ program that asks the user to enter their...
In the space provided below write a C++ program that asks the user to enter their quarterly earnings for the past two years stores the data in a 2-dimensional array. The program then computes both the annual earnings as well as the total earning and prints the results along with the 2-dimensional array on screen as well as onto a file.
In the space provided below write a ******C program********* that asks the user to enter their...
In the space provided below write a ******C program********* that asks the user to enter their quarterly earnings for the past two years stores the data in a 2-dimensional array. The program then computes both the annual earnings as well as the total earning and prints the results along with the 2-dimensional array on screen. Using the embed icon shown above, also include screenshots demoing the execution of your program. Please write carefully. Thank you
Python programming c++ Write a program that computes the amount of money the cheerleaders raised during...
Python programming c++ Write a program that computes the amount of money the cheerleaders raised during their candy bar fundraiser using the following data: 12 bars per case. The candy was sold for $1.00 per bar. Each case cost $8.00. They are required to give the student government association 10% of their earnings. The program should ask the user how many bars were sold. The program should calculate and display the SGA proceed's, the Cheer team's proceeds, and the appropriate...
Your task is to write a program in C or C++ that calculates the total amount...
Your task is to write a program in C or C++ that calculates the total amount of money a person has made over the last year. Your program will prompt the user for dollar amounts showing how much the user has made per job. Some users will have had more than one job, make sure your program allows for this. The program will print out the total made (all jobs) and will print out the federal and state taxes based...
Write a program in C that computes the area of a circle (Area = pi *...
Write a program in C that computes the area of a circle (Area = pi * r2) and the volume of a sphere (Volume = 4/3 * pi * r3). Both formulas use r which is the radius. Declare a float variable pi = 3.14159. Get the value of r from the keyboard and store it in a float variable. Display both the area of the circle and the volume of the sphere.
Write a C++ program that inputs a sequence of integers into a vector, computes the average,...
Write a C++ program that inputs a sequence of integers into a vector, computes the average, and then outputs the # of input values, the average, and the values themselves. There are 0 or more inputs values, followed by a negative value as the sentinel; the negative value is not stored and not counted. The following sample input: 10 20 0 99 -1 would produce the following output: N: 4 Avg: 32.25 10 20 0 99 The main program has...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT