Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

below are the only requirement including a simple implementation. there are no m

ID: 3631894 • Letter: B

Question

below are the only requirement including a simple implementation. there are no more instructions for the project.

*****************************************************************************



The goal of this project is to design a set of classes representing bank accounts, transactions (deposits and withdraws), and a collection of accounts. All transactions are associated with the date when they occur
All bank accounts must keep track of their current balance (always positive), and of their most recent N transactions (N depends on the type of accounts).

Savings accounts are bank accounts that are limited to 3 transactions a month, and that keep an history of the 10 most recent transactions. Savings accounts pay interest at the beginning of each month, which is recorded as a deposit not counting in the transaction limit. All savings account pay the same interest rate of 1.5%.

Checking accounts are bank accounts that have no limitation in number of transactions and keep an history of the 30 most recent transactions. Checking accounts do pay interest of 1% for balances above $10000 dollars.

A collection of accounts needs to be stored in a file, so that a program can load them up, perform some transactions, and save up the final state of each account.
The test program is intentionaly not described here, as each student has to decide how to test his own implementation.



Deliverables

source code files for the project (header, implementation, test program)

test data files

overall design

test plan, including test data and results

Code format

header comment block

appropriate comments within the code

appropriate variable and function names

correct indentation



Implementation

The only thing I can say is that I would like a base class (call it Account) and the two specific class for accounts delving from this base class.

Then you need a class to represent a portfolio of accounts.

Once you have that, you need to structure your testing too.

Whether you want two different classes to represent withdraw and deposit is up to you, but one class should be able to represent both





Explanation / Answer

#include<iostream> #include<string> #include <ctime> using namespace std;   class SavingAccount { public: int accountBalance; int numberOfTransactions[12]; double history[10]; double previousHistory[10]; int i; SavingAccount (int initial) { i=0; if(initial>=0) accountBalance=initial; else { cout<<"INVALID INITIAL BALANCE"<<endl; accountBalance=0; } } //Member function credit should add an amount to the current balance. void credit(int amount) { if(check()) { accountBalance=accountBalance+amount; updateHistory(); } } //Member function debit should withdraw money from the Account void debit(int amount) { //ensure that the debit amount does not exceed the Account’s balance. if(accountBalance<amount) { //If it does, the balance should be left unchanged and the function should //print a message indicating “Debit amount exceeded account balance.” cout<<"Debit amount exceeded account balance."<<endl; } else if(check()) { accountBalance=accountBalance-amount; updateHistory() ; } }  bool check() {  time_t rawtime; struct tm* timeinfo;  time( &rawtime ); timeinfo = localtime( &rawtime );  cout << "Today's date is " << timeinfo->tm_mday << " " <<timeinfo->tm_mon << " " << (timeinfo->tm_year + 1900) << ". "; if(numberOfTransactions[timeinfo->tm_mon]>=3) { cout<<"Maximum limit reached for month <month>: 3 transactions"; return false; } else numberOfTransactions[timeinfo->tm_mon] ++; return true; }  void updateHistory() { if(i>=10) { for(int j = 1;j<10;j++) { previousHistory[j-0] = history[j]; } previousHistory[9] = amount; history = previousHistory; } else { history[i] = amount; i ++; } } //Member function getBalance should return the current balance. int getBalance() { return accountBalance; } };   //Create a program that creates two Account objects and tests the member functions //of class Account. int main() { char ch; char acc; do{ cout<<"1. Deposit"<<endl; cout<<"2. Withdraw"<<endl; cout<<"3. Display"<<endl; cout<<"0. Exit"<<endl; cout<<"Enter your choice: "; cin>>ch; switch(ch) { case '1': { double amount; cout<<"1. Savings Account"<<endl; cout<<"2. Checking Account"<<endl; cout<<"Enter Account type: "; cin>>acc; cout<<"Enter amount to deposit: "; cin>>amount; break; } case '2': { double amount; cout<<"1. Savings Account"<<endl; cout<<"2. Checking Account"<<endl; cout<<"Enter Account type: "; cin>>acc; cout<<"Enter amount to withdraw: "; cin>>amount; break; } case '3': { break; } case '0': { system("pause"); return 0; } default: { cout<<"Invalid choice."; } } }while(true); system("pause"); return 0; }