Hey, sup yall. I gotta write this program that checks an inputted bank account's credit limit against input/expenditures, the code is below
Now, it should output this:Code:#include <iostream> using std::cout; using std::cin; using std::endl; int main() { int accountNumber; double beginningBalance; double totalCharges; double totalCredits; double creditLimit; double balance; do { cout << "Enter Account Number (-1 To End): "; cin >> accountNumber; cout << "Enter Beginning Balance: "; cin >> beginningBalance; cout << "Enter Total Charges: "; cin >> totalCharges; cout << "Enter Total Credits: "; cin >> totalCredits; cout << "Enter Credit Limit: "; cin >> creditLimit; cout << "\nAccount Number: " << accountNumber; cout << "\nCredit Limit: " << creditLimit; balance = ((beginningBalance + totalCredits) - (totalCharges)); cout << "\nBalance is: " << balance; if (balance > creditLimit) cout << "\nCredit Limit not exceeded!\n"; else cout << "\nCredit Limit exceeded!\n"; } while (accountNumber != -1); return 0; }
Should Output:
----------------
Enter Account Number (-1 To End): 100
Enter beginning balance: 5394.78
Enter Total Charges: 1000.00
Enter Total Credits: 500.00
Enter Credit Limit: 5500.00
Account: 100
Credit Limit: 5500.00
Balance: 5894.78
Credit Limit Exceeded
Enter Account Number (-1 to End): -1
But it outputs this:
Outputs:
----------
Enter Account Number (-1 To End): 100
Enter Beginning Balance: 5394.78
Enter Total Charges: 1000.00
Enter Total Credits: 500.00
Enter Credit Limit: 5500.00
Account Number: 100
Credit Limit: 5500
Balance is: 4894.78
Credit Limit exceeded!
Enter Account Number (-1 To End): -1
Enter Beginning Balance
-----
So basically neither the do while or the balance = ((beginningBalance + totalCredits) - (totalCharges)) works. So basically the program achieves nothing apart from inducing a severe headache upon myself. I've only been learning c++ a week or so, so please forgive any simple errors I've made. Can someone please point me in the direction of my error, or suggest any ways of actually making this work!?! Any comments much appreciated, thanks, peace.