Question

Please use C++. You will be provided with two files. The first file (accounts.txt) will contain...

Please use C++. You will be provided with two files. The first file (accounts.txt) will contain account numbers (10 digits) along with the account type (L:Loan and S:Savings) and their current balance. The second file (transactions.txt) will contain transactions on the accounts. It will specifically include the account number, an indication if it is a withdrawal/deposit and an amount.

Both files will be pipe delimited (|) and their format will be the following:

accounts.txt : File with bank account info (account number, account type, balance)

AcctNumber|AcctType|Balance (this first line is not part of the file)

1346782901|L|11045.43

1346782902|S|100.43

transactions.txt : File with transactions (account #, deposit/withdrawal, amount)

AcctNumber|TransactionType|Amount (this first line is not part of the file)

1346782901|D|1

1346782902|W|445.05

0346782902|W|5.06

You will need to read in all the account information from the first file and use an array of structs to store your data. Assume less than 50 records per file. You will then need a loop to read in a transaction from the second file, update the balance of the respective account according to the transaction type and then continue to the next line until all transactions are completed. If an account is not found, issue an error and continue with the next transaction. If a withdrawal is more than the current account balance, issue an error, do not perform the withdrawal and continue with the next transaction.

At the end of the program, display all accounts with their final balances in a nicely formatted manner. Moreover, create a new output file named newaccounts.txt and write all account info in the same format as the original accounts.txt file (i.e. pipe delimited). Create your own test files for accounts.txt and transactions.txt and make sure you test for all possibilities.

please show screenshots of your programming working and including the final display of the accounts and their balances.

Homework Answers

Answer #1

C++ CODING :

#include <iostream>
using namespace std;

// class
class Bank {
private:
    int acno;
    char name[30];
    long balance;

public:
    void OpenAccount()
    {
        cout << "Enter Account Number: ";
        cin >> acno;
        cout << "Enter Name: ";
        cin >> name;
        cout << "Enter  Balance: ";
        cin >> balance;
    }
    void ShowAccount()
    {
        cout << "Account Number: " << acno << endl;
        cout << "Name: " << name << endl;
        cout << "Balance: " << balance << endl;
    }
    void Deposit()
    {
        long amt;
        cout << "Enter Amount U want to deposit? ";
        cin >> amt;
        balance = balance + amt;
    }
    void Withdrawal()
    {
        long amt;
        cout << "Enter Amount U want to withdraw? ";
        cin >> amt;
        if (amt <= balance)
            balance = balance - amt;
        else
            cout << "Less Balance..." << endl;
    }
    int Search(int);
};

int Bank::Search(int a)
{
    if (acno == a) {
        ShowAccount();
        return (1);
    }
    return (0);
}

// main code
int main()
{
    Bank C[3];

    int found = 0, a, ch, i;
    for (i = 0; i <= 2; i++) {
        C[i].OpenAccount();
    }

    do {
        // display options
        cout << "\n\n1:Display All\n2:By Account No\n3:Deposit\n4:Withdraw\n5:Exit" << endl;

        // user input
        cout << "Please input your choice: ";
        cin >> ch;

        switch (ch) {
        case 1: // displating account info
            for (i = 0; i <= 2; i++) {
                C[i].ShowAccount();
            }
            break;
        case 2: // searching the record
            cout << "Account Number? ";
            cin >> a;
            for (i = 0; i <= 2; i++) {
                found = C[i].Search(a);
                if (found)
                    break;
            }
            if (!found)
                cout << "Record Not Found" << endl;
            break;
        case 3: // deposit operation
            cout << "Account Number To Deposit Amount? ";
            cin >> a;
            for (i = 0; i <= 2; i++) {
                found = C[i].Search(a);
                if (found) {
                    C[i].Deposit();
                    break;
                }
            }
            if (!found)
                cout << "Record Not Found" << endl;
            break;
        case 4: // withdraw operation
            cout << "Account Number To Withdraw Amount? ";
            cin >> a;
            for (i = 0; i <= 2; i++) {
                found = C[i].Search(a);
                if (found) {
                    C[i].Withdrawal();
                    break;
                }
            }
            if (!found)
                cout << "Record Not Found" << endl;
            break;
        case 5: // exit
            cout << "Have a nice day" << endl;
            break;
        default:
            cout << "Wrong Option" << endl;
        }
    } while (ch != 5);
    return 0;
}

OUTPUT :

I have shown it seperately for u to clearly understand.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
C++ See the provided specification files. Complete the implementation for each as a separate file. void...
C++ See the provided specification files. Complete the implementation for each as a separate file. void seen(std::string); If there is already a Word object in the Words list, then the number of occurrences for this word is incremented. If there is no Word object for this word already, create a new word object with occurrence =1, and insert this object into the list of Word objects. std::string getNextWord(); Returns the next word of the list and sets the currentItem pointer...
Create a client for your BankAccount classcalled BankAccountClient.java.    This a separate file from the BankAccount file....
Create a client for your BankAccount classcalled BankAccountClient.java.    This a separate file from the BankAccount file. Both files must be in the same directory to compile. Display all dollar amounts using the DecimalFormat class. Create an account Ask the user for the type of account, the bank account number, the amount that they will deposit to start the account. Set interest earned to 0. Print the account information using an implicit or explicit call to toString Update an account Use...
Complete this in C++ and explain what is being done. 1      Introduction The functions in the...
Complete this in C++ and explain what is being done. 1      Introduction The functions in the following subsections can all go in one big file called pointerpractice.cpp. 1.1     Basics Write a function, int square 1(int∗ p), that takes a pointer to an int and returns the square of the int that it points to. Write a function, void square 2(int∗ p), that takes a pointer to an int and replaces that int (the one pointed to by p) with its...
c# please Create a “Main” program which reads a text file called “collectionOfWords.txt”. Include exception handling...
c# please Create a “Main” program which reads a text file called “collectionOfWords.txt”. Include exception handling to check if the file exists before attempting to open it. Read and print each string to the console. Next modify each word such at the first letter in each word is uppercase and all other letters are lowercase. Display the modified word on the console. Creating a text file: Open up Notepad and type in the following words. Save the file as collectionOfWords.txt...
Katie Long owns and operates KL Company. Transactions for the month of March have been posted...
Katie Long owns and operates KL Company. Transactions for the month of March have been posted to the T accounts. An intern has prepared a trial balance from the T accounts, but there seem to be some errors. Required: 1. In the Transactions panel, descriptions of the transactions for the month of March are provided. Each of the transactions in the Transactions panel has been posted to the T accounts. Referring to the T accounts, select the date on which...
The home window main menu bar contains such functions as – Select one: a. tool buttons,...
The home window main menu bar contains such functions as – Select one: a. tool buttons, sizing buttons, open buttons, close buttons b. recording general journal entries. c. recording general ledger entries. d. file, view, setup, business assistant, maintenance, reports, history, help The date format used in a Sage 50 data file- Select one: a. applies to all Sage 50 data files b. is set for the individual data file c. cannot be changed after you set it up d....
Carlos Perez has a NOW account at the First State Bank. His checkbook ledger lists the...
Carlos Perez has a NOW account at the First State Bank. His checkbook ledger lists the following checks: Check Numbers Amount 654 $206.05 658 55.02 662 103.00 668 99.06 670 6.18 671 50.39 672 24.90 673 32.16 674 44.50 675 30.00 676 30.00 677 111.23 678 38.04 679 97.99 680 486.84 681 43.50 682 75.04 683 98.55 Carlos also made the following withdrawals and deposits at an ATM near his home: Date Amount Transaction 11/1 $50.00 withdrawal 11/2 $525.60 deposit...
For Java For this assignment you will develop two classes called ATM and Customer that simulate...
For Java For this assignment you will develop two classes called ATM and Customer that simulate an imaginary automated teller machine (ATM). In the assignment, you should also develop a UML class diagram for the ATM class and a jUnit test case. In the program, we assume that an ATM initially keeps $100.00 cash for customer transactions. Additionally, we assume that there are a total of ten customers combined for the Union Bank and BOA banks. This is a list...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in Lab 2 to obtain a diameter value from the user and compute the volume of a sphere (we assumed that to be the shape of a balloon) in a new program, and implement the following restriction on the user’s input: the user should enter a value for the diameter which is at least 8 inches but not larger than 60 inches. Using an if-else...
please can you make it simple. For example using scanner or hard coding when it is...
please can you make it simple. For example using scanner or hard coding when it is a good idea instead of arrays and that stuff.Please just make one program (or class) and explain step by step. Also it was given to me a txt.htm 1.- Write a client program and a server program to implement the following simplified HTTP protocol based on TCP service. Please make sure your program supports multiple clients. The webpage file CS3700.htm is provided. You may...