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

STEP 1: Create the Multifile Project and the Main (Base) Class Create a new proj

ID: 3549296 • Letter: S

Question

STEP 1: Create the Multifile Project and the Main (Base) Class

Create a new project that consists of the base class BankAccount.

The BankAccount class should contain, at minimum, the following members.

STEP 2: Create the CheckingAccount Class Derived From the BankAccount Class

The class CheckingAccount should contain, at a minimum, the following members.

STEP 3: Create the SavingsingAccount Class Derived From the BankAccount Class

The class CheckingAccount should contain, at a minimum, the following members.

STEP 4: Test Program Operation

STEP 1: Create the Multifile Project and the Main (Base) Class

Three charges are fixed to an x, y coordinate system, at distances dx=3 m and dy=4 m as shown in the figure, where ?=53.1 degree. The charges are q1 = 18 ?C, q2 = -12 ?C, and q3 = 45 ?C. Determine the magnitude of the electrostatic force F13 on q3 due to q1 What is the y component of F13? Find the magnitude of the force F23 on charge q3 due to charge q2 Determine the x component of the net electrostatic force Fx on q3 Determine the magnitude the net electrostatic force F on q3

Explanation / Answer

#include <iostream>

#include <time.h>

using namespace std;

class BankAccount

{

public:

// constructors

BankAccount(){};

BankAccount(int);

// getters and setters

void setAccountNumber(int);

int getAccountNumber();

double getBalance();

void setBalance(double);

// account operations

void deposit(double);

bool withdraw(double);

protected:

int accountNumber; //account number

double balance; //balance

};

// member function definitions of BankAccount class

BankAccount::BankAccount(int num)

{

setAccountNumber(num);

balance = 0;

}

void BankAccount::setAccountNumber(int num)

{

accountNumber = num;

}

int BankAccount::getAccountNumber(){

return accountNumber;

}

double BankAccount::getBalance(){

return balance;

}

void BankAccount::setBalance(double bal){

balance = bal;

}

//deposits specified amount

void BankAccount::deposit(double amount)

{

balance = balance + amount;

}

//return true if withdrawl is successful

//otherwise returns false

bool BankAccount::withdraw(double amount)

{

if(balance < amount)

return false;

else

{

balance = balance - amount;

return true;

}

}

/* =======================================

* Checking Account inherits from BankAccount

* ======================================= */

class CheckingAccount :public BankAccount

{

public:

CheckingAccount();

CheckingAccount(int);

bool withdraw(double);

private:

int numOfWithdrawls; // number of withdrawl count

};

// member function definitions of CheckingAccount class

CheckingAccount::CheckingAccount():BankAccount()

{

numOfWithdrawls = 0;

}

CheckingAccount::CheckingAccount(int num):BankAccount(num)

{

numOfWithdrawls = 0;

}

// overridden withdrawl method

bool CheckingAccount::withdraw(double amount)

{

if(numOfWithdrawls > 3)

amount = amount + 50;

numOfWithdrawls++;

if( balance < amount)

return false;

else

balance = balance - amount;

return true;

}

/* =======================================

* Savings Account inherits from BankAccount

* ======================================= */

class SavingsAccount :public BankAccount

{

public:

SavingsAccount();

SavingsAccount(int);

void setAnnualInterest(double);

double getBalance();

double intEarnedSinceLastTrans();

int numOfDaysSinceLastTrans();

private:

// daily interest rate

double dailyInterestRate;

//interets earned since last transaction

double intEarnSinceLastTrans;

// number of days since last transaction occured

int numOfDays;

};

// member function definitions of SavingsAccount class

SavingsAccount::SavingsAccount():BankAccount()

{

numOfDays = rand()%8;

}

SavingsAccount::SavingsAccount(int num):BankAccount(num)

{

numOfDays = rand()%8;

}

void SavingsAccount::setAnnualInterest(double rate)

{

dailyInterestRate = rate/365;

}

int SavingsAccount::numOfDaysSinceLastTrans()

{

return numOfDays;

}

double SavingsAccount::intEarnedSinceLastTrans()

{

return numOfDays * dailyInterestRate;

}

double SavingsAccount::getBalance()

{

balance = balance + (numOfDays * dailyInterestRate);

numOfDays = rand()%8;

return balance;

}

//main function

int _tmain(int argc, _TCHAR* argv[])

{

srand(time(NULL));

//saving and checking acc objetcs

SavingsAccount sa(12345);

CheckingAccount ca(54321);

//sets initila balance

sa.setBalance(100);

ca.setBalance(100);

//sets annual interets rate

sa.setAnnualInterest(0.03);

//displaying account details

cout<<"Account Number: "<<sa.getAccountNumber()<<endl;

cout<<"Account Type: Savings"<<endl;

cout<<"Balance: $"<<sa.getBalance()<<endl;

cout<<"Number of days since last transcation: "<<sa.numOfDaysSinceLastTrans()<<endl;

cout<<"Interest earned since last transaction: $"<<sa.intEarnedSinceLastTrans()<<endl;

cout<<" Account Number: "<<ca.getAccountNumber()<<endl;

cout<<"Account Type: Checking"<<endl;

cout<<"Balance: $"<<ca.getBalance()<<endl;

return 0;

}