Answer to Question #161804 in C++ for Anonymous

Question #161804

Bank ChargesA bank charges $10 per month plus the following check fees for a commercial check- ing account:$.10 each for fewer than 20 checks$.08 each for 20–39 checks$.06 each for 40–59 checks$.04 each for 60 or more checksThe bank also charges an extra $15 if the balance of the account falls below $400 (before any check fees are applied).Write a program that asks for the beginning balance and the number of checks written. Compute and display the bank’s service fees for the month.
Input Validation: Do not accept a negative value for the number of checks written. If a negative value is given for the beginning balance, display an urgent message indicating the account is overdrawn.

 

View sample output




 


1
Expert's answer
2021-02-15T00:08:12-0500
#include <iostream>
using namespace std;
int main()
{
	int numberOfChecks;
	double accountAmount;
	double endBalance = 0;
	double sumOfCharges = 0;
	cout << "Enter account balance ($): ";
	cin >> accountAmount;
	if (accountAmount < 0)
	{
		cout << "Pay attention! Account is overdrawn!" << endl;
		return 0;
	}
	for (bool i = false; i == false;)
	{
		cout << "Enter number of checks: ";
		cin >> numberOfChecks;
		if (numberOfChecks < 0)
		{
			cout << "Wrong number of checks." << endl;
			continue;
		}
		i = true;
	}
	
	cout << endl;
	if (accountAmount < 400)
	{
		cout << "Extra charge $15: (balance of the account falls below $400)" << endl;
		sumOfCharges += 15;
		endBalance = accountAmount - 15;
	}
	if (numberOfChecks < 20)
	{
		cout << "Charge for checks: " << (double)numberOfChecks * 0.1 << "$";
		endBalance -= (double)numberOfChecks * 0.1;
		sumOfCharges += (double)numberOfChecks * 0.1;
	}
	if (numberOfChecks >= 20 && numberOfChecks < 40)
	{
		cout << "Charge for checks: " << (double)numberOfChecks * 0.08 << "$";
		endBalance -= (double)numberOfChecks * 0.08;
		sumOfCharges += (double)numberOfChecks * 0.08;
	}
	if (numberOfChecks >= 40 && numberOfChecks < 60)
	{
		cout << "Charge for checks: " << (double)numberOfChecks * 0.06 << "$";
		endBalance -= (double)numberOfChecks * 0.06;
		sumOfCharges += (double)numberOfChecks * 0.06;
	}
	if (numberOfChecks >= 60)
	{
		cout << "Charge for checks: " << (double)numberOfChecks * 0.04 << "$";
		endBalance -= (double)numberOfChecks * 0.04;
		sumOfCharges += (double)numberOfChecks * 0.04;
	}
	cout << endl;
	cout << "Bank charge $10 per month." << endl << endl;
	sumOfCharges += 10;
	cout << "Sum of all bank fees is: " << sumOfCharges << "$" << endl;
	return 0;
}
 
 

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog