I have written a program for updating a customer's account balance and am having a problem ending the looping part of it.
Here is my source code:
I am sure that it is a simple solution that I am just overlooking after 2 hours of trying to stop the loop.Code:#include <iostream> using std::cout; using std::cin; using std::endl; using std::fixed; #include <iomanip> using std::setprecision; int main( ) { int accountNumber; // customers account number double beginningBalance; // customers balance double totalCharges; // charges on the account double totalCredits; // credits to the account double creditLimit; // credit limit on the account double newBalance; // new beginning balance cout << setprecision( 1 ) << fixed; while( accountNumber != -1 ) { cout << "Enter account Number: " << endl; cin >> accountNumber; cout << "Enter beginning balance: " << endl; cin >> beginningBalance; cout << "Enter total charges: " << endl; cin >> totalCharges; cout << "Enter total credit: " << endl; cin >> totalCredits; cout << "Enter credit limit: " << endl; cin >> creditLimit; } if ( beginningBalance >= creditLimit ) { cout << "Account: " << accountNumber << endl; cout << "Credit limit: " << creditLimit << endl; cout << "Balance: " << beginningBalance << endl; cout << "Credit Limit Exceeded" << endl; } else { cout << "Enter beginning balance: " << endl; cin >> beginningBalance; cout << "Enter total charges: " << endl; cin >> totalCharges; cout << "Enter total credit: " << endl; cin >> totalCredits; cout << "Enter credit limit: " << endl; cin >> creditLimit; } newBalance = beginningBalance + totalCharges - totalCredits; return 0; }![]()



LinkBack URL
About LinkBacks



