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

I cant get this program to meet some of the requirements for my assignment i nee

ID: 3772843 • Letter: I

Question

I cant get this program to meet some of the requirements for my assignment i need a little help please.

1.The Account class must be an abstract class with two pure virtual functions, closeMonth

and accountString.

2. The balance, withdrawal and deposit manipulation must use the methods in the base

class Account.

3. Each action must display appropriate messages indicating that the action was

completed.

4. The closeMonth and accountString functions must be called polymorphically. This

means, they are called for each account without checking to see what kind of account it

is being called on.

5. An implication of the last point is that there will be a single array of Account objects,

some of which are Checking accounts and some of which are Savings accounts.

MAIN.CPP

#include <iostream>

#include <string>

#include <fstream>

#include "Header.h"

using namespace std;

int main()

{

  

Checking accCh[9];

  

Savings accSB[9];

  

int cno=0,sno=0;

  

ifstream infile("bank2.txt");

  

infile.open("bank2.txt");

  

string line;

  

if(!infile)

  

{

  

cout<<"Error opening file ";

  

system("pause");

  

exit(0);

  

}

  

while(!infile.eof())

  

{

  

infile>>line;

  

if(line.compare("Savings")==0)

  

{

  

int acno;

  

double initialBalance,minimumBalance, monthlyFee;

  

infile>>acno;

  

accSB[sno].setId(acno);

  

infile>>initialBalance>>minimumBalance>>monthlyFee;

  

accSB[sno].setBalance(initialBalance);

  

accSB[sno].minBalance(minimumBalance);

  

accSB[sno].APR(monthlyFee);

  

sno++;

  

}

  

else if(line.compare("Checking")==0)

  

{

  

int acno;

  

double initialBalance,minimumBalance,monthlyFee;

  

infile>>acno;

  

accCh[cno].setId(acno);

  

infile>>initialBalance>>minimumBalance>>monthlyFee;

  

accCh[cno].setBalance(initialBalance);

  

accCh[cno].minBalance(minimumBalance);

  

accCh[cno].monthlyFee(monthlyFee);

  

cno++;

  

}

  

else if(line.compare("Deposit")==0)

  

{

  

int acno;

  

double amount;

  

infile>>acno>>amount;

  

accSB[acno].deposit(amount);

  

}

  

else if(line.compare("Withdraw")==0)

  

{

  

int acno;

  

double amount;

  

infile>>acno>>amount;

  

accSB[acno].withdraw(amount);

  

}

  

else if(line.compare("Balance")==0)

  

{

  

int acno;

  

infile>>acno;

  

cout<<"The current balance is:"<<accSB[acno].getBalance()<<endl;

  

}

  

else if(line.compare("Close")==0)

  

{

  

for(int i=0;i<sno;i++)

  

accSB[i].closeMonth();

  

for(int i=0;i<cno;i++)

  

accCh[i].closeMonth();

  

cout<<"End of month processing complete."<<endl;

  

}

  

else if(line.compare("Report")==0)

  

{

  

for(int i=0;i<sno;i++)

  

cout<<"Savings account #"<<accSB[i].getId()

  

<<"has a balance of $"<<accSB[i].getBalance()<<endl;

  

for(int i=0;i<cno;i++)

  

cout<<"Checking account #"<<accCh[i].getId()

  

<<"has a balance of $"<<accCh[i].getBalance()<<endl;

  

}

  

else

  

{

  

cout<<"Bad Command."<<endl;

  

}

  

}

  

system("pause");

  

return 0;

  

}

HEADER.H

#ifndef Header_h

#define Header_h

#include <iostream>

#include <string>

using namespace std;

class Account

{

  

public:

  

Account();

  

Account(int newId, double initialBalance);

  

void setId(int newId);

  

int getId() { return id; };

  

void setBalance(double newBalance);

  

double getBalance() { return balance; };

  

void withdraw(double amount);

  

void deposit(double amount);

  

private:

  

int id;

  

double balance;

  

};

class Checking: public Account

{

  

private:

  

double minBal,monthFee;

  

public:

  

double minBalance(double minimum);

  

double monthlyFee(double fee);

  

void closeMonth();

  

string accountString();

  

};

class Savings: public Account

{

  

private:

  

double minBal,arp;

  

public:

  

double minBalance(double minmum);

  

double APR(double interestRate);

  

void closeMonth();

  

string accountString();

  

};

#endif

HEADER.CPP

#include <stdio.h>

#include "Header.h"

#include <string>

#include <cmath>

using namespace std;

Account::Account()

{

  

balance = 0;

  

}

Account::Account(int newId, double initialBalance)

{

  

id = newId;

  

balance = initialBalance;

  

}

void Account::setId(int newId)

{

  

id = newId;

  

}

void Account::setBalance(double newBalance)

{

  

balance = newBalance;

  

}

void Account::withdraw(double amount)

{

  

balance = balance - amount;

  

}

void Account::deposit(double amount)

{

  

balance = balance + amount;

  

}

//implementation of checking

double Checking::minBalance(double x)

{

  

minBal=x;

  

return minBal;

  

}

double Checking::monthlyFee(double x)

{

  

monthFee=x;

  

return monthFee;

  

}

void Checking::closeMonth ()

{

  

}

string Checking::accountString()

{

  

return " ";

  

}

//implmentaino of Savings

void Savings::closeMonth ()

{

  

}

string Savings::accountString()

{

  

return " ";

  

}

double Savings::minBalance(double x)

{

  

minBal=x;

  

return minBal;

  

}

double Savings::APR(double x)

{

  

arp=x;

  

return arp;

  

}

BANK.TXT

Savings 1 1000.01 1000.00 4.0
Checking 2 2000.02 2500.00 6.95
Savings 3 3000.03 2000 7.0
Deposit 1 11.11
Deposit 2 22.22
Withdraw 4 5000.00
Checking 4 4000.04 2000.00 11.99
Withdraw 1 0.10
Balance 2
Withdraw 2 0.20
Deposit 3 33.33
Withdraw 4 0.40
Bad Command 65
Close
Report

Explanation / Answer

//HEADER.H
#ifndef Header_h

#define Header_h

#include <iostream>

#include <string>

using namespace std;

class Account

{
  
public:
  
Account();
  
Account(int newId, double initialBalance);
  
void setId(int newId);
  
int getId() { return id; };
  
void setBalance(double newBalance);
  
double getBalance() { return balance; };
  
void withdraw(double amount);
  
void deposit(double amount);
  
virtual void closeMonth();
  
virtual string accountString();
  
private:
  
int id;
  
double balance;
  
};

class Checking: public Account

{
  
private:
  
double minBal,monthFee;
  
public:
  
double minBalance(double minimum);
  
double monthlyFee(double fee);
  
virtual void closeMonth();
  
virtual string accountString();
  
};

class Savings: public Account

{
  
private:
  
double minBal,arp;
  
public:
  
double minBalance(double minmum);
  
double APR(double interestRate);
  
virtual void closeMonth();
  
virtual string accountString();
};

#endif

//HEADER.CPP
#include <stdio.h>

#include "Header.h"

#include <string.h>

#include <cmath>

using namespace std;

Account::Account()

{
  
balance = 0;
  
}

Account::Account(int newId, double initialBalance)

{
  
id = newId;
  
balance = initialBalance;
  
}

void Account::setId(int newId)

{
  
id = newId;
  
}

void Account::setBalance(double newBalance)

{
  
balance = newBalance;
  
}

void Account::withdraw(double amount)

{
  
balance = balance - amount;
  
}

void Account::deposit(double amount)

{
  
balance = balance + amount;
  
}

//implementation of checking

double Checking::minBalance(double x)

{
  
minBal=x;
  
return minBal;
  
}

double Checking::monthlyFee(double x)

{
  
monthFee=x;
  
return monthFee;
  
}

void Checking::closeMonth ()
{
//if
}

string Checking::accountString()
{
string msg=" Minimum Balance: "+to_string(minBal)+" Monthly Fee: "+to_string(monthFee);
return msg;
  
}

//implmentaino of Savings

void Savings::closeMonth ()

{
  
}

string Savings::accountString()

{
  
string msg=" Minimum Balance: "+to_string(minBal)+" ARP: "+to_string(Arp);
return msg;
  
  
}

double Savings::minBalance(double x)

{
  
minBal=x;
  
return minBal;
  
}

double Savings::APR(double x)

{
  
arp=x;
  
return arp;
  
}

//MAIN.CPP
#include <iostream>

#include <string>

#include <fstream>

#include "Header.cpp"

using namespace std;

int main()

{
  
Checking accCh[9];
  
Savings accSB[9];
  
int cno=0,sno=0;
  
ifstream infile;
  
infile.open("bank.txt");
  
string line;
  
if(!infile)
  
{
  
cout<<"Error opening file ";
  
system("pause");
  
exit(0);
  
}
  
while(!infile.eof())
  
{
  
infile>>line;
  
if(line.compare("Savings")==0)
  
{
  
int acno;
  
double initialBalance,minimumBalance, monthlyFee;
  
infile>>acno;
  
accSB[sno].setId(acno);
  
infile>>initialBalance>>minimumBalance>>monthlyFee;
  
accSB[sno].setBalance(initialBalance);
  
accSB[sno].minBalance(minimumBalance);
  
accSB[sno].APR(monthlyFee);
  
sno++;
  
}
  
else if(line.compare("Checking")==0)
  
{
  
int acno;
  
double initialBalance,minimumBalance,monthlyFee;
  
infile>>acno;
  
accCh[cno].setId(acno);
  
infile>>initialBalance>>minimumBalance>>monthlyFee;
  
accCh[cno].setBalance(initialBalance);
  
accCh[cno].minBalance(minimumBalance);
  
accCh[cno].monthlyFee(monthlyFee);
  
cno++;
  
}
  
else if(line.compare("Deposit")==0)
  
{
  
int acno;
  
double amount;
  
infile>>acno>>amount;
  
accSB[acno].deposit(amount);
  
}
  
else if(line.compare("Withdraw")==0)
  
{
  
int acno;
  
double amount;
  
infile>>acno>>amount;
  
accSB[acno].withdraw(amount);
  
}
  
else if(line.compare("Balance")==0)
  
{
  
int acno;
  
infile>>acno;
  
cout<<"The current balance is:"<<accSB[acno].getBalance()<<endl;
  
}
  
else if(line.compare("Close")==0)
  
{
  
for(int i=0;i<sno;i++)
  
accSB[i].closeMonth();
  
for(int i=0;i<cno;i++)
  
accCh[i].closeMonth();
  
cout<<"End of month processing complete."<<endl;
  
}
  
else if(line.compare("Report")==0)
  
{
  
for(int i=0;i<sno;i++)
  
cout<<"Savings account #"<<accSB[i].getId()
  
<<"has a balance of $"<<accSB[i].getBalance()<<endl;
  
for(int i=0;i<cno;i++)   
  
cout<<"Checking account #"<<accCh[i].getId()
  
<<"has a balance of $"<<accCh[i].getBalance()<<endl;
  
}
  
else
  
{
  
cout<<"Bad Command."<<endl;
  
}   
  
}
  
system("pause");
  
return 0;
  
}

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