// Homework #6 // Problem 2.17 // // Develop a C++ program that will determine if a department store customer // has exceeded the credit limit on a charge account. For each, customer, the // following facts are available: // // a.) Account number (integer) // b.) Balance at the beginning of the month // c.) Total of all items charged by this customer this month // d.) Total of all credits applied to this customer's account this month // e.) Allowed credit limit. // // The program should input each of these facts, calculate the new balance // ( = beginning balance + charges - credits), and determine if the new balance // exceeds the customer's credit limit. For those customers whose credit limit // is exceeded, the program should display the customer's account number, // credit limit, new balance, and the message "Credit limit exceeded." // #include main() { int act_num=0; float ttl_chg; float beg_bal; float new_bal; float ttl_credits; float credit_limit; cout << "Enter account number (-1 to end): "; cin >> act_num; while( act_num != -1 ) { cout << "Enter the Beginning Balance: "; cin >> beg_bal; cout << "Enter the Total Charges: "; cin >> ttl_chg; cout << "Enter the Total Credits: "; cin >> ttl_credits; cout << "Enter Credit Limit: "; cin >> credit_limit; new_bal = beg_bal + ttl_chg - ttl_credits; if ( new_bal > credit_limit ) { cout << "\tAccount: " << act_num << endl; cout << "\tCredit Limit: " << credit_limit << endl; cout << "\tBalance: " << new_bal << endl; cout << "***** Credit limit Exceeded! *****\n\n"; } cout << "\nEnter account number (-1 to end): "; cin >> act_num; } return 0; }