Answer:
#include <iostream> // For including input output functions
using namespace std; // used by computer to identify cout cin endl
int main() { start of the body of main function
int Account_Number; // stores the account number
double starting_balance; //stores beginning balance
double total_charges; // stores all items charged
double total_credit; // stores total credits applied to customers account
double credit_limit; // stores allowed credit limit
double new_balance; //stores the new balance
while( Account_Number != -1 ) // loop continues until acc no is -1
{ cout<<"Please Enter The Account Number " ;
//prompts the user to enter the account number
cin>>Account_Number; // reads account number
cout<< "Please Enter Beginning Balance: " ;
cin>>starting_balance ; //reads beginning balance
cout<< "Please Enter the Total Charges: " ;
cin>>total_charges; //reads total charges
cout<< "Please Enter Total Credits: " ;
cin>>total_credit; // reads total credits
cout<< "Please Enter Credit Limit: " ;
cin>>credit_limit ; //reads credit limit
// calculates the new balance
new_balance = starting_balance + total_charges - total_credit;
// checks if the new balance exceeds customers credit limit
if ( new_balance > credit_limit ) {
/* if the credit limit is exceeded, the program displays the customer’s account number, credit limit, new balance and the message "Credit Limit Exceeded */
cout<< "Account Number:"<<Account_Number<<endl;
cout<< "Credit Limit:"<< credit_limit<<endl;
cout<< "New Balance:"<<new_balance<<endl;
cout<< "Credit Limit Exceeded."<<endl ; }
cout << "Please Enter Account Number (-1 to end): "<<endl;
cin >> Account_Number;} }
Explanation:
This program calculates the new balance by adding beginning balance and total charges and subtracting total credits applied to the customer from starting balance and total charges. If statement is used here to check the condition if the new balance exceeded the credit limit. If this is true then the program displays customer’s account number, credit limit, new balance and the message "Credit Limit Exceeded. While loop here will continue to execute until the user enters -1.