/*Date: 02/11/08 Programming Fundamentals II Homework Assignment Chapter 4-Question #4.10 Bank Charges - A bank charges $10 per month plus the following check fees for a commercial checking 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 checks Write a program that asks for the number of checks written during the past month, then computes and displays the bank's fees for the month. Input Validation: Do not accept a negative value for the number of checks written. */ #include #include using namespace std; int main() { //create double variables to hold input and fees double checks =0, totalfee =0, fee = 10, fee1 =.1, fee2 = .08, fee3 = .06, fee4 = .04, first =0, second =0, third =0, fourth =0; //create bool variable for ending of program bool closing = true; //Welcome user and introduce program, then ask for input from user cout << "Welcome to Hector's Monthly Check Fees Calculator, Build 1.0\n"; cout << "Please enter the number of checks you wrote for the past month.\n"; cin >> checks; //if user inputs negative number, gives user following message and sets closing to false if (checks < 0) { cout << "ERROR: You cannot enter a negative amount of checks!\n"; closing = false; } //takes input from user and figures monthly bank fees if(checks <20) first = (checks * fee1); if(checks >= 20 && checks <= 39) second = (19*fee1) + ((checks-19) * fee2); if(checks >= 40 && checks <= 59) third = (19*fee1) + (20 * fee2)+((checks-39) * fee3); if(checks >= 60) fourth =(19*fee1) + (20 * fee2)+(20 * fee3)+((checks-59) * fee4); //adds all fees together totalfee = (fee+first+second+third+fourth); //if closing true(because user didn't enter negative number, show total fees if (closing) cout <<"Your total monthly Bank Fees are $" << fixed << setprecision(2) << totalfee <<".\n"; //thank user for using program cout <<"Thank You for using my program.\n"; return 0; }