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

I am having trouble with a C++ program, that must be done in Microsoft Visual St

ID: 3631872 • Letter: I

Question

I am having trouble with a C++ program, that must be done in Microsoft Visual Studio 2010.
This is the cpp file that contains errors where there are += or-= and there is also an error where it says if(double balance-a<0) at the -a.

#include <iostream>
#include <iomanip>

#include "bankAccount.h"
#include "savingsAccount.cpp"

using namespace std;


class checkingAccount:public bankAccount
{
public:
checkingAccount(int accNum, double bal);
double getMinBal();
double getRate();
double getFee();
void setMinBal(double);
void setRate(double);
void setFee(double);
void postInterest();
bool checkMinBal(double);
void checkingAccount::writeCheck(double);
void withdraw(double);
void print();
private:
double rate, minBal,fee;
};

bankAccount::bankAccount(int n,double b)
{accNum=n;
balance=b;
}
void bankAccount::setAccNum(int a)
{accNum=a;
}
int bankAccount::getAccNum()
{return accNum;
}
double bankAccount::getBalance()
{return balance;
}
void bankAccount::withdraw(double a)
{balance-=a;
}
void bankAccount::deposit(double a)
{balance+=a;
}
void bankAccount::print()
{cout<<accNum<<"Balance: $"<<setprecision(2)<<fixed<<balance<<endl;
}
checkingAccount::checkingAccount(int n,double b):bankAccount(n,b)
{setRate(.04);
setMinBal(500);
setFee(20);
}
double checkingAccount::getMinBal()
{return minBal;
}
double checkingAccount::getRate()
{return rate;
}
double checkingAccount::getFee()
{return fee;
}
void checkingAccount::setMinBal(double m)
{minBal=m;
}
void checkingAccount::setRate(double r)
{rate=r;
}
void checkingAccount::setFee(double f)
{fee=f;
}
void checkingAccount::postInterest()
{double balance+=(balance*rate);
}
bool checkingAccount::checkMinBal(double a)
{if(double balance-a>=minBal)
return true;
else
return false;
}
void checkingAccount::writeCheck(double a)
{
withdraw(a);
}
void checkingAccount::withdraw(double a)
{
if(double balance-a<0)
cout<<"insufficient funds for $"<<a<<" withdrawal ";
else if(balance-a<minBal)
if(balance-a-fee<minBal)
cout<<"insufficient funds for withdrawal + fees, since balance will be below minimum ";
else
{cout<<"balance below minimum. $"<<fee<<" fee charged ";
balance-=(a+fee);
}
else
balance-=a;
}
void checkingAccount::print()
{cout<<"Interest Checking ACCT#: "<<getAccNum()
<<" Balance: $"<<setprecision(2)<<fixed<<getBalance()<<endl;
}
savingsAccount::savingsAccount(int n,double b):bankAccount(n,b)
{setRate(.06);
}
double savingsAccount::getRate()
{return rate;
}
void savingsAccount::setRate(double r)
{rate=r;
}
void savingsAccount::withdraw(double a)
{
if(double balance-a<0)
cout<<"insufficient funds for $"<<setprecision(2)<<fixed<<" withdrawal ";
else
balance-=a;
}
void savingsAccount::postInterest()
{double balance+=(balance*rate);
}
void savingsAccount::print()
{cout<<"Savings ACCT#: "<<getAccNum()
<<" Balance: $"<<setprecision(2)<<fixed<<getBalance()<<endl;
}
int main()

I would also like to know how to test my classes assuming the following transactions (adding the necessary comments in the output). The user must be prompted for these options: I will be given a data file in class to test my program and I would like to know how to design my program to run and also run when the tested data file will be given to me.

Set Account Numbers 1000, 1001, 1002, 1004 to

Create Checking Account for Jack with $1000
Create Checking Account for Lisa with $450
Create Checking Account for Samir with $9300
Create Checking Account for Rita with $32

Deposit $1000 into Jack's Checking Account
Deposit $2300 into Lisa's Checking Account
Deposit $800 into Samir's Checking Account
Deposit $500 into Rita's Checking Account

Post Interest on Jack's Checking Account
Post Interest on Lisa's Checking Account
Post Interest on Samir's Checking Account
Post Interest on Rita's Checking Account

Print Jack's Checking Account Information
Print Lisa's Checking Account Information
Print Samir's Checking Account Information
Print Rita's Checking Account Information

Jack writes a check in the amount of $250
Lisa writes a check in the amount of $350
Samir withdraws the amount of $120
Rita withdraws the amount of $290

Print Jack's Checking Account Information
Print Lisa's Checking Account Information
Print Samir's Checking Account Information
Print Rita's Checking Account Information

Here is a full copy of my programming assignment:
The data file will be given to you in class for acceptance testing
a. Define the class bankAccount to store a bank customer’s account number and balance. Suppose that account number is of type int, and balance is of type double. Your class should, at least, provide the following operations: set the account number, retrieve the account number, retrieve the balance, deposit and withdraw money, and print account information. Add appropriate constructors.

b. Every bank offers a checking account. Derive the class checkingAccount from the class bankAccount (designed in part (a)). This class inherits members to store the account number and the balance from the base class. A customer with a checking account typically receives interest, maintains a minimum balance, and pays service charges if the balance falls below the minimum balance. Add member variables to store this additional information. In addition to the operations inherited from the base class, this class should provide the following operations: set interest rate, retrieve interest rate, set minimum balance, retrieve minimum balance, set service charges, retrieve service charges, post interest, verify if the balance is less than the minimum balance, write a check, withdraw (override the method of the base class), and print account information. Add appropriate constructors.

c. Every bank offers a savings account. Derive the class savingsAccount from the class bankAccount (designed in part ( a)). This class inherits members to store the account number and the balance from the base class. A customer with a savings account typically receives interest, makes deposits, and withdraws money. In addition to the operations inherited from the base class, this class should provide the following operations: set interest rate, retrieve interest rate, post interest, withdraw (override the method of the base class), and print account information. Add appropriate constructors.

d. You need to separate the classes into their .h and .cpp files.

e. Test your classes designed in parts (b) and (c). Assume the following transactions (please add the necessary comments in the output) (DO NOT HARDCODE these inputs in your program, prompt the user for these options):(Which are above starting with Set account numbers)

Explanation / Answer

please rate - thanks

balance is already defined, so every place you have double balance, remove the double

#include <iostream>
#include <iomanip>

#include "bankAccount.h"
#include "savingsAccount.cpp"

using namespace std;
class checkingAccount:public bankAccount
{
public:
checkingAccount(int accNum, double bal);
double getMinBal();
double getRate();
double getFee();
void setMinBal(double);
void setRate(double);
void setFee(double);
void postInterest();
bool checkMinBal(double);
void checkingAccount::writeCheck(double);
void withdraw(double);
void print();
private:
double rate, minBal,fee;
};

bankAccount::bankAccount(int n,double b)
{accNum=n;
balance=b;
}
void bankAccount::setAccNum(int a)
{accNum=a;
}
int bankAccount::getAccNum()
{return accNum;
}
double bankAccount::getBalance()
{return balance;
}
void bankAccount::withdraw(double a)
{balance-=a;
}
void bankAccount::deposit(double a)
{balance+=a;
}
void bankAccount::print()
{cout<<accNum<<"Balance: $"<<setprecision(2)<<fixed<<balance<<endl;
}
checkingAccount::checkingAccount(int n,double b):bankAccount(n,b)
{setRate(.04);
setMinBal(500);
setFee(20);
}
double checkingAccount::getMinBal()
{return minBal;
}
double checkingAccount::getRate()
{return rate;
}
double checkingAccount::getFee()
{return fee;
}
void checkingAccount::setMinBal(double m)
{minBal=m;
}
void checkingAccount::setRate(double r)
{rate=r;
}
void checkingAccount::setFee(double f)
{fee=f;
}
void checkingAccount::postInterest()
{balance+=(balance*rate);
}
bool checkingAccount::checkMinBal(double a)
{if(balance-a>=minBal)
return true;
else
return false;
}
void checkingAccount::writeCheck(double a)
{
withdraw(a);
}
void checkingAccount::withdraw(double a)
{
if(balance-a<0)
cout<<"insufficient funds for $"<<a<<" withdrawal ";
else if(balance-a<minBal)
if(balance-a-fee<minBal)
cout<<"insufficient funds for withdrawal + fees, since balance will be below minimum ";
else
{cout<<"balance below minimum. $"<<fee<<" fee charged ";
balance-=(a+fee);
}
else
balance-=a;
}
void checkingAccount::print()
{cout<<"Interest Checking ACCT#: "<<getAccNum()
<<" Balance: $"<<setprecision(2)<<fixed<<getBalance()<<endl;
}
savingsAccount::savingsAccount(int n,double b):bankAccount(n,b)
{setRate(.06);
}
double savingsAccount::getRate()
{return rate;
}
void savingsAccount::setRate(double r)
{rate=r;
}
void savingsAccount::withdraw(double a)
{
if( balance-a<0)
cout<<"insufficient funds for $"<<setprecision(2)<<fixed<<" withdrawal ";
else
balance-=a;
}
void savingsAccount::postInterest()
{balance+=(balance*rate);
}
void savingsAccount::print()
{cout<<"Savings ACCT#: "<<getAccNum()
<<" Balance: $"<<setprecision(2)<<fixed<<getBalance()<<endl;
}
int main()

{int acct=1000;  
checkingAccount Jack(acct++,1000);
checkingAccount Lisa(acct++, 450);
savingsAccount Samir(acct++, 9300);   
savingsAccount Rita(acct++, 32);
Jack.deposit(1000);
Lisa.deposit(2300);   
Samir.deposit(800);   
Rita.deposit(500);
Jack.postInterest();
Lisa.postInterest();
Samir.postInterest();
Rita.postInterest();
Jack.print();   
Lisa.print();
Samir.print();
Rita.print();   
Jack.writeCheck(250);
Lisa.writeCheck(350);   
Samir.withdraw(120);   
Rita.withdraw(290);
Jack.print();
Lisa.print();
Samir.print();
Rita.print();
system("pause");
return 0;
}