In this program the user will enter transaction information
In this program the user will enter transaction information for their checking account.
    For each transaction, they will enter:
   Type (C=Check, D=Deposit, W=Withdrawl)
    Amount
   The Amount entered by the user should always be a positive amount, even if its effect on
    the balance is negative (like a Check for $123).
   The information that the user enters must be stored in parallel arrays (one for the transaction
    type and another for the amount). The user is in control of how many transactions to enter
    (up to the maximum number as defined by the MAX_NUMBER_OF_TRANSACTIONS constant).
   After the user is done entering transactions, the program will produce a chart listing the
    transactions. Additionally, an ending balance will be calculated and displayed (assume the
    beginning balance was $0).
   To complete this exam, follow the TODO steps listed below. Remember that each part of this exam
    is worth points, so be sure to complete everything that you know how to do as quickly as you can.
    Also, as always, to get a perfect score it is necessary to write a program that matches the
    Sample Output (shown at the bottom) using the proper techniques taught in this course.
*/
#include <iostream>
 #include <string>
 #include <iomanip>
using namespace std;
int main()
 {
    const int MAX_NUMBER_OF_TRANSACTIONS = 6;
   /* TODO - Step 1
    Declare 2 arrays, with data types and names listed below - each
    holding as many values as determined by the constant declared above:
   - array of char, named transactionTypes
    - array of double, named transactionAmounts
    */
// Parallel array declarations
    // Additional variables
    int index = 0;           // used while entering transactions, keeps track of current array position within the loop
    char again;               // loop control variable, holds \'Y\' if user wants to add another transaction
   /* TODO - Step 2
    Complete the DO...WHILE loop that has been started here. You will need to scroll down to where the following line
    is commented out:
//} while (expression)
   Uncomment the line and change \"expression\" so the loop repeats if:
        - the user indicated they want to add another transaction, AND
        - fewer than MAX_NUMBER_OF_TRANSACTIONS have been added
    */
   do
    {
        /* TODO - Step 3
        - Prompt the user for the transaction type
        - Read the user\'s answer and store to the correct array in the correct location
        - Convert the answer the user gave to uppercase and store the result back to the same array location
        */
        /* TODO - Step 4
        Write a WHILE loop to validate the user\'s entry. If the user\'s entry was not a C, not a D, and
        not a W:
        - Display the error message
        - Read the user\'s answer again and store to the correct array in the same location
        - Convert the new answer the user gave to uppercase and store the result back to the same array location
        */
        /* TODO - Step 5
        - Prompt the user for the transaction amount
        - Read the user\'s answer and store to the correct array in the correct location
        */
      
        /* TODO - Step 6
        Write a WHILE loop to validate the user\'s entry. If the user\'s entry was less than or equal to 0:
        - Display the error message
        - Read the user\'s answer again and store to the correct array in the same location
        */
        /* TODO - Step 7
        Increment the array index variable, readying it for the next time around the loop
        */
        /* TODO - Step 8
        If the parallel array index is still less than the max number of transactions allowed
        (as identified by the MAX_NUMBER_OF_TRANSACTIONS constant), then:
        - as the user if they want to enter another transaction
        - read the user\'s answer from the keyboard into the variable provided for this purpose
        - convert the user\'s answer to lowercase and store it back to the loop control variable (again)
        */
        cout << endl;
   //} while (expression)
    // END OF THE DO...WHILE LOOP
    // This is the spot that Step 2 told you to look for and change
   int i;                   // the for loop control variable
    double balance = 0;       // an accumulator to sum the balance based on the transactions
    double amount;           // a temporary variable to hold a transaction\'s amount
   // Display the header for the transaction ledger
    cout << \"T Amount\" << endl;
    cout << \"- --------\" << endl;
cout << fixed << setprecision(2);
   /* TODO - Step 9
    Write a for loop that will loop based on the number of transaction entered above.
    */
   //for (initialize; test; increment)
    {
        /* TODO - Step 10
        Output the transaction type as the first character on the line, within a two
        character column (setw...)
        */
        /* TODO - Step 11
        If the transaction is one that subtracts from the balance (a Check or Withdrawal)
            store the negative of the transactionAmount to the amount variable
        Otherwise
            store the transactionAmount (without changing it) to the amount variable
        */
        /* TODO - Step 12
        Output the amount within an eight character column (use setw...)
        */
        /* TODO - Step 13
        Properly update the balance using the amount value
        */
}
cout << \"==========\" << endl << endl;
   /* TODO - Step 14
    Output the line that displays the ending balance
    */
    return 0;
 }
/* Sample Output
Enter the transaction type (D=Deposit, C=Check, W=Withdrawl): y
 ERROR: Transaction type must be D, C, or W - Enter again: D
 Enter the transaction amount: 500
 Enter another transaction (y/n): y
Enter the transaction type (D=Deposit, C=Check, W=Withdrawl): C
 Enter the transaction amount: 123.45
 Enter another transaction (y/n): y
Enter the transaction type (D=Deposit, C=Check, W=Withdrawl): W
 Enter the transaction amount: -200
 ERROR: Transaction amount must be greater than 0 - Enter again: 200
 Enter another transaction (y/n): y
Enter the transaction type (D=Deposit, C=Check, W=Withdrawl): d
 Enter the transaction amount: 893.20
 Enter another transaction (y/n): y
Enter the transaction type (D=Deposit, C=Check, W=Withdrawl): w
 Enter the transaction amount: 250
 Enter another transaction (y/n): y
Enter the transaction type (D=Deposit, C=Check, W=Withdrawl): c
 Enter the transaction amount: 444.44
T Amount
 - --------
 D 500.00
 C -123.45
 W -200.00
 D 893.20
 W -250.00
 C -444.44
 ==========
Ending Balance = $375.31
 Press any key to continue . . .
Solution
#include <iostream>
 #include <string>
 #include <iomanip>
 using namespace std;
 int main()
 {
 const int MAX_NUMBER_OF_TRANSACTIONS = 6;
 /* TODO - Step 1
 Declare 2 arrays, with data types and names listed below - each
 holding as many values as determined by the constant declared above:
 - array of char, named transactionTypes
 - array of double, named transactionAmounts
 */
 // Parallel array declarations
    char transactionTypes[MAX_NUMBER_OF_TRANSACTIONS];
    double transactionAmounts[MAX_NUMBER_OF_TRANSACTIONS];
// Additional variables
 int index = 0; // used while entering transactions, keeps track of current array position within the loop
 char again; // loop control variable, holds \'Y\' if user wants to add another transaction
 /* TODO - Step 2
 Complete the DO...WHILE loop that has been started here. You will need to scroll down to where the following line
 is commented out:
 //} while (expression)
 Uncomment the line and change \"expression\" so the loop repeats if:
 - the user indicated they want to add another transaction, AND
 - fewer than MAX_NUMBER_OF_TRANSACTIONS have been added
 */
 do
 {
 /* TODO - Step 3
 - Prompt the user for the transaction type
 - Read the user\'s answer and store to the correct array in the correct location
 - Convert the answer the user gave to uppercase and store the result back to the same array location
 */
        cout<<\"Enter the transaction type (D=Deposit, C=Check, W=Withdrawl): \";
        cin>>transactionTypes[index];
        transactionTypes[index] = toupper(transactionTypes[index]);
/* TODO - Step 4
 Write a WHILE loop to validate the user\'s entry. If the user\'s entry was not a C, not a D, and
 not a W:
 - Display the error message
 - Read the user\'s answer again and store to the correct array in the same location
 - Convert the new answer the user gave to uppercase and store the result back to the same array location
 */
        while(transactionTypes[index] != \'D\' && transactionTypes[index] != \'C\' && transactionTypes[index] != \'W\'){
            cout<<\"ERROR: Transaction type must be D, C, or W - Enter again: \";
            cin>>transactionTypes[index];
            transactionTypes[index] = toupper(transactionTypes[index]);
        }
/* TODO - Step 5
 - Prompt the user for the transaction amount
 - Read the user\'s answer and store to the correct array in the correct location
 */
        cout<<\"Enter the transaction amount: \";
        cin>>transactionAmounts[index];
   
 /* TODO - Step 6
 Write a WHILE loop to validate the user\'s entry. If the user\'s entry was less than or equal to 0:
 - Display the error message
 - Read the user\'s answer again and store to the correct array in the same location
 */
        while(transactionAmounts[index] <= 0){
            cout<<\"ERROR: Amount must be more than 0.Enter again: \";
            cin>>transactionAmounts[index];
        }
/* TODO - Step 7
 Increment the array index variable, readying it for the next time around the loop
 */
        index++;
/* TODO - Step 8
 If the parallel array index is still less than the max number of transactions allowed
 (as identified by the MAX_NUMBER_OF_TRANSACTIONS constant), then:
 - as the user if they want to enter another transaction
 - read the user\'s answer from the keyboard into the variable provided for this purpose
 - convert the user\'s answer to lowercase and store it back to the loop control variable (again)
 */
        if(index<6){
            cout<<\"Enter another transaction (y/n): \";
            cin>>again;
           
            again = tolower(again);
        }
cout << endl;
 } while (again == \'y\' && index < MAX_NUMBER_OF_TRANSACTIONS);
 // END OF THE DO...WHILE LOOP
 // This is the spot that Step 2 told you to look for and change
 
 int i; // the for loop control variable
 double balance = 0; // an accumulator to sum the balance based on the transactions
 double amount; // a temporary variable to hold a transaction\'s amount
 // Display the header for the transaction ledger
 cout << \"T Amount\" << endl;
 cout << \"- --------\" << endl;
 cout << fixed << setprecision(2);
 /* TODO - Step 9
 Write a for loop that will loop based on the number of transaction entered above.
 */
 for (int i=0; i<MAX_NUMBER_OF_TRANSACTIONS; i++)
 {
 /* TODO - Step 10
 Output the transaction type as the first character on the line, within a two
 character column (setw...)
 */
        cout<< setw(2) <<transactionTypes[i];
       
 /* TODO - Step 11
 If the transaction is one that subtracts from the balance (a Check or Withdrawal)
 store the negative of the transactionAmount to the amount variable
 Otherwise
 store the transactionAmount (without changing it) to the amount variable
 */
        if(transactionTypes[i]==\'C\' || transactionTypes[i]==\'W\'){
            amount = -transactionAmounts[i];
        }
        else
            amount = transactionAmounts[i];
 /* TODO - Step 12
 Output the amount within an eight character column (use setw...)
 */
        cout<< setw(8) <<amount;
        cout<< endl;
 /* TODO - Step 13
 Properly update the balance using the amount value
 */
        balance+=amount;
 }
 cout << \"==========\" << endl << endl;
 /* TODO - Step 14
 Output the line that displays the ending balance
 */
    cout<<\"Ending Balance = $\"<<balance;
 cout<<\"\ Press any key to continue . . .\ \";
   
 return 0;
 }






