#include <iostream>
#include <iomanip> // For setting output precision
using namespace std;
int main() {
double balance, serviceCharge = 10.0, checkFee = 0.0, extraFee = 0.0;
int numChecks;
// Ask for the beginning balance and number of checks written
cout << "Enter the beginning balance: $";
cin >> balance;
// Validate the balance to ensure it's not negative
if (balance < 0) {
cout << "Error: The beginning balance cannot be negative.\n";
return 1;
}
cout << "Enter the number of checks written: ";
cin >> numChecks;
// Validate the number of checks to ensure it's not negative
if (numChecks < 0) {
cout << "Error: The number of checks cannot be negative.\n";
return 1;
}
// Determine the check fee based on the number of checks
if (numChecks < 20) {
checkFee = 0.10 * numChecks;
} else if (numChecks >= 20 && numChecks <= 39) {
checkFee = 0.08 * numChecks;
} else if (numChecks >= 40 && numChecks <= 59) {
checkFee = 0.06 * numChecks;
} else {
checkFee = 0.04 * numChecks;
}
// If the balance is below $400, add the extra fee
if (balance < 400) {
extraFee = 15.0;
}
// Calculate the total service charges
double totalFee = serviceCharge + checkFee + extraFee;
// Output the result
cout << fixed << setprecision(2); // Format output to 2 decimal places
cout << "\nBank Service Fees for the Month:\n";
cout << "-----------------------------------\n";
cout << "Base Service Charge: $" << serviceCharge << endl;
cout << "Check Fees: $" << checkFee << endl;
if (extraFee > 0) {
cout << "Extra Fee (Balance below $400): $" << extraFee << endl;
}
cout << "Total Service Charges: $" << totalFee << endl;
return 0;
}