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.
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.
Get Answers For Free
Most questions answered within 1 hours.