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

This Application stores every transaction as soon as a transaction happens. Only

ID: 3737859 • Letter: T

Question


This Application stores every transaction as soon as a transaction happens. Only amount of the transaction is stored, the date of transaction or any other data is not stored by this class.
When the application starts, it will ask the user about what is the maximum number of expected transactions. You will assume that the balance is zero when the program first starts.
The application will allow the user to make deposits as long as the balance is not above $100,000 FDIC limit.
The application will allow users to withdraw money as long as the withdrawal amount is no more than the available balance.
The application will allow the user to print the available balance at anytime.
The application will also allow the banker to print following statistics regarding the account at any time: balance total deposits total withdrawals average deposit amount average withdrawal amount minimum deposit amount minimum withdrawal amount maximum deposit amount maximum withdrawal amount variance of all the deposits variance of all the withdrawal standard deviation of all the deposits standard deviation of all the withdrawal This Application stores every transaction as soon as a transaction happens. Only amount of the transaction is stored, the date of transaction or any other data is not stored by this class.
When the application starts, it will ask the user about what is the maximum number of expected transactions. You will assume that the balance is zero when the program first starts.
The application will allow the user to make deposits as long as the balance is not above $100,000 FDIC limit.
The application will allow users to withdraw money as long as the withdrawal amount is no more than the available balance.
The application will allow the user to print the available balance at anytime.
The application will also allow the banker to print following statistics regarding the account at any time: balance total deposits total withdrawals average deposit amount average withdrawal amount minimum deposit amount minimum withdrawal amount maximum deposit amount maximum withdrawal amount variance of all the deposits variance of all the withdrawal standard deviation of all the deposits standard deviation of all the withdrawal Design All the three “Applications” will use object(s) of a common “utility” class called “Statistics” that will maintain a dynamically allocated array of doubles [5 points]. The data will be stored in that array.
Statistics Class [20 points] This class will provide functions that are shown in the UML class diagram shown below. Their functionalities are obvious from their names, but ask if you are not sure about any one.
The function add() adds a double value at the end of the array. The function get() obtains a copy of the value stored at the location i. The function set() overwrites (changes) the value stored at the location i by the provided value. The printStats() function invokes all other stats related functions and prints them on the screen. Design All the three “Applications” will use object(s) of a common “utility” class called “Statistics” that will maintain a dynamically allocated array of doubles [5 points]. The data will be stored in that array.
Statistics Class [20 points] This class will provide functions that are shown in the UML class diagram shown below. Their functionalities are obvious from their names, but ask if you are not sure about any one.
The function add() adds a double value at the end of the array. The function get() obtains a copy of the value stored at the location i. The function set() overwrites (changes) the value stored at the location i by the provided value. The printStats() function invokes all other stats related functions and prints them on the screen.
Here are the functions in UML format so you can copy-n-paste add(value: double): void get(i: int): double set(i: int, data: double): void sum(): double average(): double min(): double max(): double var(): double stdev(): double printStats(): void
BankAccount Class [30 points] This class will have two instances of Statistics class. One will be used to store deposits and other one will be used to store withdrawals. This is different from how we implemented this class in the Midterm. Here are the functions in UML format so you can copy-n-paste add(value: double): void get(i: int): double set(i: int, data: double): void sum(): double average(): double min(): double max(): double var(): double stdev(): double printStats(): void
BankAccount Class [30 points] This class will have two instances of Statistics class. One will be used to store deposits and other one will be used to store withdrawals. This is different from how we implemented this class in the Midterm.
Here are the functions in UML format so you can copy-n-paste: deposit(amount: double): void withdrawal(amount: double): void getBalance(): double getTotalDeposits(): double getTotalWithdrawals(): double getAverageDeposit(): double getAverageWithdrawal(): double getMinDeposit(): double getMinWithdrawal(): double getMaxDeposit(): double getMaxWithdrawal(): double getVarOfDeposits(): double getVarOfWithdrawal(): double getStdevOfDeposits(): double getStdevOfWithdrawal(): double printAllStats(): void Here are the functions in UML format so you can copy-n-paste: deposit(amount: double): void withdrawal(amount: double): void getBalance(): double getTotalDeposits(): double getTotalWithdrawals(): double getAverageDeposit(): double getAverageWithdrawal(): double getMinDeposit(): double getMinWithdrawal(): double getMaxDeposit(): double getMaxWithdrawal(): double getVarOfDeposits(): double getVarOfWithdrawal(): double getStdevOfDeposits(): double getStdevOfWithdrawal(): double printAllStats(): void
Implementation Notes For every class, all error conditions (in functions where errors can take place) must be identified and exceptions must be written and thrown. The exceptions must be “caught” only in the test() and process methods. [10 points]
For every class that you write, please implement a generic print() function [5 points] that prints all the data “owned” by that class directly or indirectly. Also implement static test() function that tests all other functions without any user input (all values that are otherwise expected from the user will be hard coded), and at least 5 new entries into the array.
Exceptions All Exception classes can be written inside a single file called “project1exceptions.hmyexceptions.h”. The constructors and functions of exception classes can be “inlined” like shown in the class. See lecture on Exceptions. Let us have a discussion about Exceptions here. Please list the exceptions that you feel must be there below (I will start with one):
NoDataException This exception will be thrown by a function in Statistics class that needs the size of the array to be greater than zero. Implementation Notes For every class, all error conditions (in functions where errors can take place) must be identified and exceptions must be written and thrown. The exceptions must be “caught” only in the test() and process methods. [10 points]
For every class that you write, please implement a generic print() function [5 points] that prints all the data “owned” by that class directly or indirectly. Also implement static test() function that tests all other functions without any user input (all values that are otherwise expected from the user will be hard coded), and at least 5 new entries into the array.
Exceptions All Exception classes can be written inside a single file called “project1exceptions.hmyexceptions.h”. The constructors and functions of exception classes can be “inlined” like shown in the class. See lecture on Exceptions. Let us have a discussion about Exceptions here. Please list the exceptions that you feel must be there below (I will start with one):
NoDataException This exception will be thrown by a function in Statistics class that needs the size of the array to be greater than zero.




BankAccount deposit (amount: double) void withdrawal (amount: double): void getBalance () double getTotalDeposits): double getTotalWithdrawals (): double getAverageDeposit): double getAveragWithdrawal): double getMinDeposit double getMinWithdrawal ): double getMaxDeposit): double get: doublel MaxWithdrawa getVarOfDeposits ): double getVarOfWithdrawal): double getStdevOfDeposits ):double getStdevOfWithdrawal) double printAllstats ) void withdrawals deposits Statistics

Explanation / Answer

here the code for the given problem

#include<iostream>
#include<fstream>
#include<cctype>
#include<iomanip>
using namespace std;

class account
{
   int accnum;
   char name[50];
   int depositosit;
   char type;
public:
   void createAcc();
   void showAcc() const;
   void modify();  
   void deposit(int);  
   void draw(int);  
   void report() const;
   int retaccnum() const;
   int retdepositosit() const;  
   char rettype() const;  
};       

void account::createAcc()
{
   cout<<" Enter The account No. :";
   cin>>accnum;
   cout<<" Enter The Name of The account Holder : ";
   cin.ignore();
   cin.getline(name,50);
   cout<<" Enter Type of The account (C/S) : ";
   cin>>type;
   type=toupper(type);
   cout<<" Enter The Initial amount(>=500 for Saving and >=1000 for current ) : ";
   cin>>depositosit;
   cout<<" Account Created..";
}

void account::showAcc() const
{
   cout<<" Account No. : "<<accnum;
   cout<<" Account Holder Name : ";
   cout<<name;
   cout<<" Type of Account : "<<type;
   cout<<" Balance amount : "<<depositosit;
}

void account::modify()
{
   cout<<" Account No. : "<<accnum;
   cout<<" Modify Account Holder Name : ";
   cin.ignore();
   cin.getline(name,50);
   cout<<" Modify Type of Account : ";
   cin>>type;
   type=toupper(type);
   cout<<" Modify Balance amount : ";
   cin>>depositosit;
}

void account::deposit(int x)
{
   depositosit+=x;
}
  
void account::draw(int x)
{
   depositosit-=x;
}
  
void account::report() const
{
   cout<<accnum<<setw(10)<<" "<<name<<setw(10)<<" "<<type<<setw(6)<<depositosit<<endl;
}

  
int account::retaccnum() const
{
   return accnum;
}

int account::retdepositosit() const
{
   return depositosit;
}

char account::rettype() const
{
   return type;
}

void write_account();
void display_sp(int);
void modify_account(int);  
void delete_account(int);  
void display_all();      
void depositosit_withdraw(int, int);
void intro();

int main()
{
   char ch;
   int num;
   intro();
   do
   {
       system("cls");
       cout<<" MAIN MENU";
       cout<<" 01. NEW ACCOUNT";
       cout<<" 02. DEPOSIT AMOUNT";
       cout<<" 03. WITHDRAW AMOUNT";
       cout<<" 04. BALANCE ENQUIRY";
       cout<<" 05. ALL ACCOUNT HOLDER LIST";
       cout<<" 06. CLOSE AN ACCOUNT";
       cout<<" 07. MODIFY AN ACCOUNT";
       cout<<" 08. EXIT";
       cout<<" Select Your Option (1-8) ";
       cin>>ch;
       system("cls");
       switch(ch)
       {
       case '1':
           write_account();
           break;
       case '2':
           cout<<" Enter The account No. : "; cin>>num;
           depositosit_withdraw(num, 1);
           break;
       case '3':
           cout<<" Enter The account No. : "; cin>>num;
           depositosit_withdraw(num, 2);
           break;
       case '4':
           cout<<" Enter The account No. : "; cin>>num;
           display_sp(num);
           break;
       case '5':
           display_all();
           break;
       case '6':
           cout<<" Enter The account No. : "; cin>>num;
           delete_account(num);
           break;
       case '7':
           cout<<" Enter The account No. : "; cin>>num;
           modify_account(num);
           break;
       case '8':
           cout<<" Thanks for using bank managemnt system";
           break;
       default :cout<<"";
       }
       cin.ignore();
       cin.get();
   }while(ch!='8');
   return 0;
}

void write_account()
{
   account ac;
   ofstream outFile;
   outFile.open("account.dat",ios::binary|ios::app);
   ac.createAcc();
   outFile.write(reinterpret_cast<char *> (&ac), sizeof(account));
   outFile.close();
}

void display_sp(int n)
{
   account ac;
   bool flag=false;
   ifstream inFile;
   inFile.open("account.dat",ios::binary);
   if(!inFile)
   {
       cout<<"File could not be open !! Press any Key...";
       return;
   }
   cout<<" BALANCE DETAILS ";
       while(inFile.read(reinterpret_cast<char *> (&ac), sizeof(account)))
   {
       if(ac.retaccnum()==n)
       {
           ac.showAcc();
           flag=true;
       }
   }
   inFile.close();
   if(flag==false)
       cout<<" Account number does not exist";
}

void modify_account(int n)
{
   bool found=false;
   account ac;
   fstream File;
   File.open("account.dat",ios::binary|ios::in|ios::out);
   if(!File)
   {
       cout<<"File could not be open !! Press any Key...";
       return;
   }
   while(!File.eof() && found==false)
   {
       File.read(reinterpret_cast<char *> (&ac), sizeof(account));
       if(ac.retaccnum()==n)
       {
           ac.showAcc();
           cout<<" Enter The New Details of account"<<endl;
           ac.modify();
           int pos=(-1)*static_cast<int>(sizeof(account));
           File.seekp(pos,ios::cur);
           File.write(reinterpret_cast<char *> (&ac), sizeof(account));
           cout<<" Record Updated";
           found=true;
          }
   }
   File.close();
   if(found==false)
       cout<<" Record Not Found ";
}

void delete_account(int n)
{
   account ac;
   ifstream inFile;
   ofstream outFile;
   inFile.open("account.dat",ios::binary);
   if(!inFile)
   {
       cout<<"File could not be open !! Press any Key...";
       return;
   }
   outFile.open("Temp.dat",ios::binary);
   inFile.seekg(0,ios::beg);
   while(inFile.read(reinterpret_cast<char *> (&ac), sizeof(account)))
   {
       if(ac.retaccnum()!=n)
       {
           outFile.write(reinterpret_cast<char *> (&ac), sizeof(account));
       }
   }
   inFile.close();
   outFile.close();
   remove("account.dat");
   rename("Temp.dat","account.dat");
   cout<<" Record Deleted ..";
}

void display_all()
{
   account ac;
   ifstream inFile;
   inFile.open("account.dat",ios::binary);
   if(!inFile)
   {
       cout<<"File could not be open !! Press any Key...";
       return;
   }
   cout<<" ACCOUNT HOLDER LIST ";
        cout<<"A/c no.      NAME           Type Balance ";
       while(inFile.read(reinterpret_cast<char *> (&ac), sizeof(account)))
   {
       ac.report();
   }
   inFile.close();
}

void depositosit_withdraw(int n, int option)
{
   int amt;
   bool found=false;
   account ac;
   fstream File;
   File.open("account.dat", ios::binary|ios::in|ios::out);
   if(!File)
   {
       cout<<"File could not be open !! Press any Key...";
       return;
   }
   while(!File.eof() && found==false)
   {
       File.read(reinterpret_cast<char *> (&ac), sizeof(account));
       if(ac.retaccnum()==n)
       {
           ac.showAcc();
           if(option==1)
           {
               cout<<" TO DEPOSITE AMOUNT ";
               cout<<" Enter The amount to be depositosited";
               cin>>amt;
               ac.deposit(amt);
           }
           if(option==2)
           {
               cout<<" TO WITHDRAW AMOUNT ";
               cout<<" Enter The amount to be withdraw";
               cin>>amt;
               int bal=ac.retdepositosit()-amt;
               if((bal<500 && ac.rettype()=='S') || (bal<1000 && ac.rettype()=='C'))
                   cout<<"Insufficience balance";
               else
                   ac.draw(amt);
           }
           int pos=(-1)*static_cast<int>(sizeof(ac));
           File.seekp(pos,ios::cur);
           File.write(reinterpret_cast<char *> (&ac), sizeof(account));
           cout<<" Record Updated";
           found=true;
           }
         }
   File.close();
   if(found==false)
       cout<<" Record Not Found ";
}

void intro()
{
   cout<<" BANK";
   cout<<" MANAGEMENT";
   cout<<" SYSTEM";
   cout<<" MADE BY : your name";
   cout<<" SCHOOL : your school name";
   cin.get();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote