I have written a little program from an example problem in a book. I am wondering if you guys would look at it and tell me if this is the most efficient way to do this or is there a better way?
Code:#include <iostream.h> int con, acctNum = 0; double bal, totalCharge, totalCredit, credLimit, totalBal, newBal = 0.0; int main() { while(acctNum != -1) { cout << "Enter account number(-1 to exit): \n"; cin >> acctNum; if(acctNum == -1) {break;} cout << "Enter beginning balance:\n"; cin >> bal; cout << "Enter total charges:\n"; cin >> totalCharge; cout << "Enter total credits:\n"; cin >> totalCredit; cout << "Enter credit limit:\n"; cin >> credLimit; cout << "Account: " << acctNum << "\n"; cout << "Credit limit: " << credLimit << "\n"; totalBal = ((bal - (totalCharge) + (totalCredit))); newBal = ((bal + (totalCharge) - (totalCredit))); if(newBal > credLimit) {cout << "Credit Limit Exceeded.\n";} cout << "Balance: " << totalBal << "\n"; } }



LinkBack URL
About LinkBacks


