A bank charges $10 per month plus the following check fees for a commercial checking account:

$.10 each for less than 20 checks
$.08 each for 20-39 cecks
$.06 each for 40-59 checks
$.04 each for 60 or more checks

The 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. Compare 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.

her is what i have so far, if you don't mind could you tell me the operations i need to figure this out:

#include <iomanip>
#include <iostream>
using namespace std;

int main()
{
	double begbal, checkw, ppch, banksf;
	banksf = 10
	cout << "Enter your beginning balance ";
	cin >> begbal;
	cout << "Enter the number of written checks ";
	cin >> checkw

	if (checkw < 20)
		ppch = .10
	else if (checkw == 20 || checkw <= 39)
			ppch = .08
	else if (checkw == 40 || checkw <= 59)
			ppch = .06
	else if (checkw > 60)
			ppch = .04
	else
		cout << fixed << setprecision(2);
		
	return 0;
}
Member Avatar for iamthwee

Use a while or a do while condition to neglect negative input.

You can save writing, and unnecessary testing in your check charge section:

if (checkw < 20)
		ppch = .10
	else if (checkw == 20 || checkw <= 39)
	         ppch = .08
	else if (checkw == 40 || checkw <= 59)
		ppch = .06
	else if (checkw > 60)
		ppch = .04
	else
		cout << fixed << setprecision(2);

lines 3 and 5 don't need to check for equality to the low end, the fact the previous test was false ensures that.
Line 7 can simply be an else - you know the number of checks is 60 or more by the time you get here.
Why do you have the formatting statement as part of this if...else block? It should stand alone.
Revision:

if (checkw < 20)
		ppch = .10
	else if ( checkw <= 39)
		ppch = .08
	else if ( checkw <= 59)
		ppch = .06
	else 
		ppch = .04
	
	cout << fixed << setprecision(2); //should be moved elsewhere in code

From here, you need to test the balance to determine if penalty applies, then deduct fees from balance.

Of course, in between lines 11 and 13 of your original post, you must check for negative balance, display the message required. It's not clear whether you then exit the program, or let the user try again.

//Chpt4prgm11
//Micah Standing

#include <iomanip>
#include <iostream>
using namespace std;

int main()
{
	double begbal, checkw, ppch, bankaf, extrabf;
	bankaf = 10
	extrabf = 15
	cout << "Enter your beginning balance ";
	cin >> begbal;
	cout << "Enter the number of written checks ":
	cin << checkw
               


                cout << fixed << setprecision(2);
	if (checkw < 20)
			ppch = .10
	else if ( checkw <=39)
			ppch = .08
	else if (checkw <=59)
			ppch = .06
	else
			ppch = .04

im not understanding, where does the equations for the negatice balance and what u mean when u say i need to test the balance, then deduct fees and also is the setpercision command in the right place, also does that extrabf thing ok its for the extra $15 if it's below $400.

Why did you start a new thread? You should have just added to your existing thread so that people would know what in the world you are talking about.

can you explain your question bit more...

all i want to know is what equations i need for this problem and if i got my setprecision in the right place.

dangerdev beginning balance * checks writting * price per check; is this one of the equations i need for this program, if it is, is there anything else i need to add to it. also where in the program do i put something about the extra $15 if less then $400. also if the setprecision is in the right place on my program.

use nested if...check first if checkw is less than zero to avoid the negative input...u can modify it to re-request for an input or to quit

don't forget to put semicolons after statements
anyway,

for the additional $15 if balance is < $400

if (begbal<400)
total_bank_fees += 15;

equation for check fees:

total_check_fees = ppch * checkw;

then just add everything

total_bank_fees += total_check_fees;

use do while for the validation of balance

do {
cin>>begbal;
if (begbal<0)
cout<<"Your account is overdrawn.";
}while (begbal<0);

then do the same with checks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.