1) The attached file credits debits.cpp is a buggy version of a program to satisfy the requirements that follow. Edit the file to satisfy the requirements. a) Start with a balance of $500 b) Each line of input should include an integer amount in SUS of a transaction, some white space, and then a description of the transaction. c) Stop the loop when the end of the input is detected. Note that since the line should start with the amount, we can take advantage of the implementation of >>, which returns O if there is nothing left to match the desired type to read in d) If the amount is positive, it is a credit. If the amount is negative, it is a debit. Output description of transaction and indicate resulting balance c) If a debit would take the balance below zero (a balance of exactly is ok here), output error message to the cer stream instead of cout. Exit the loop but not the program (so you should still output the ending summary). 1) If the amount is zero, output error message to the cerr stream indicating that the transaction is invalid and will be ignored 8) Output a summary of the transactions: Number of credit transactions Total amount of these credits Number of accepted debit transactions Total amount of these debits Final balance h) Here is a sample run: Reads in a list of bank transactions and outputs summary information Enter the amount of the next transaction (in $US), then the transaction description 30 returned desk lamp returned desk lamp of $30 leaves balance = $530 Enter the amount of the next transaction (in SUS), then the transaction description -5 donuts donuts of $-5 leaves balance - $525 Enter the amount of the next transaction (in SUS), then the transaction description O testing Ignoring transaction of so testing of $0 leaves balance - $525 Enter the amount of the next transaction in SUS), then the transaction description -100 ATM withdrawal ATM withdrawal of $-100 leaves balance = $425 Enter the amount of the next transaction (in SUS), then the transaction description - 450 pay plumber to fix leak pay plumber to fix leak of $-450 is greater than balance - $425 Credits -1 Total credits - $30 Debits - 2 Total debits - S-105 Pinal balance - 425 Loops, part 1 */ #include
#include #include #include using namespace std; int main() const int STARTING_BALANCE = 500; int balance = STARTING_BALANCE; int amt; // of next transaction string desc; // description of transaction int numCredits, numDebits; int creditSum, debitTotal; cout > amt; while (balance > 0) { numCredits = numDebits = credit Sum= debitTotal = 0; if (amt > 0) { numCredits+1; creditSum += amt; else { numDebits+1; debitTotal - amt; balance = amt; getline(cin, desc); cout