Q make comments for each conde Accounth include using names

(((((Q \\ make comments for each conde??))))))

//Account.h

#include<iostream>

using namespace std;

#ifndef ACCOUNT_H

#define ACCOUNT_H

class SavingsAccount

{

double savingsBalance;

static double annualInterestRate;

public:

SavingsAccount(double b);

void calculateMonthlyInterest();

static void modifyInterestRate(double r);

void printBalance() const;

};

#endif

//Account.cpp

#include<iostream>

using namespace std;

#include\"account.h\"

SavingsAccount::SavingsAccount(double b)

{

if (b>0)

savingsBalance = b;

else

savingsBalance = 0;

}

void SavingsAccount::calculateMonthlyInterest(){

savingsBalance = savingsBalance*(1 + (annualInterestRate / 12));

}

void SavingsAccount::modifyInterestRate(double r)

{

if (r>0)

annualInterestRate = r;

else

annualInterestRate = 0.03;

}

void SavingsAccount::printBalance()const

{

cout << \"$ \" << savingsBalance << endl;

}

double SavingsAccount::annualInterestRate = 0; // initializer

//main.cpp

#include<iostream>

using namespace std;

#include\"account.h\"

int main()

{

SavingsAccount saver1(2000.00), saver2(3000.00);

cout << \"Savings Account Initial Balance of saver1: \";

saver1.printBalance();

SavingsAccount::modifyInterestRate(3);

saver1.calculateMonthlyInterest();

cout << endl << \"Savings Account Balance of saver1: \";

saver1.printBalance();

cout << endl << \"Savings Account Initial Balance of saver1: \";

saver1.printBalance();

saver2.calculateMonthlyInterest();

cout << endl << \"Savings Account Balance of saver2: \";

saver2.printBalance();

}

Solution

//Account.h

#include<iostream>   //include a header file that is part of the C++ standard library (the name stands for Input/Output Stream)

using namespace std; //The built in C++ library routines are kept in the standard namespace. That includes stuff like cout, cin, string, vector, map, etc.

#ifndef ACCOUNT_H   // #ifndef checks whether the given token has been #defined earlier in the file or in an included file; if not, it includes the code between it and the closing #else or, if no #else is present, #endif statement.

#define ACCOUNT_H   // #define creates a macro, which is the association of an identifier or parameterized // identifier with a token string

class SavingsAccount       //create a class named SavingsAccont

{

double savingsBalance;       //define variables of type double

static double annualInterestRate; // A static holds the value / data even after the function has exited and will retain // this value until the app exits.

public: //all variables and functions in this section are public

SavingsAccount(double b);

void calculateMonthlyInterest();

static void modifyInterestRate(double r);

void printBalance() const;

};

#endif

//Account.cpp   

#include<iostream>

using namespace std;

#include\"account.h\"

SavingsAccount::SavingsAccount(double b)      //SavingsAccount constructor which extends SavingsAccount

{

if (b>0)

savingsBalance = b;

else

savingsBalance = 0;

}

void SavingsAccount::calculateMonthlyInterest(){   //calculateMontlyInterest extends SavingsAccount

savingsBalance = savingsBalance*(1 + (annualInterestRate / 12)); //calculate balance

}

void SavingsAccount::modifyInterestRate(double r)   //modifyInterestrate extends savings account

{

if (r>0)

annualInterestRate = r;

else

annualInterestRate = 0.03;

}

void SavingsAccount::printBalance()const //return value if the function is a const

{

cout << \"$ \" << savingsBalance << endl;

}

double SavingsAccount::annualInterestRate = 0; // initializer

//main.cpp

#include<iostream>

using namespace std;

#include\"account.h\"

int main()

{

SavingsAccount saver1(2000.00), saver2(3000.00); //create two objects for SavingsAccount class which can hold //max of 2000 and 3000 balance respectively

cout << \"Savings Account Initial Balance of saver1: \";

saver1.printBalance();

SavingsAccount::modifyInterestRate(3);

saver1.calculateMonthlyInterest();

cout << endl << \"Savings Account Balance of saver1: \";

saver1.printBalance();

cout << endl << \"Savings Account Initial Balance of saver1: \";

saver1.printBalance();

saver2.calculateMonthlyInterest();

cout << endl << \"Savings Account Balance of saver2: \";

saver2.printBalance();

}

(((((Q \\ make comments for each conde??)))))) //Account.h #include<iostream> using namespace std; #ifndef ACCOUNT_H #define ACCOUNT_H class SavingsAccoun
(((((Q \\ make comments for each conde??)))))) //Account.h #include<iostream> using namespace std; #ifndef ACCOUNT_H #define ACCOUNT_H class SavingsAccoun
(((((Q \\ make comments for each conde??)))))) //Account.h #include<iostream> using namespace std; #ifndef ACCOUNT_H #define ACCOUNT_H class SavingsAccoun
(((((Q \\ make comments for each conde??)))))) //Account.h #include<iostream> using namespace std; #ifndef ACCOUNT_H #define ACCOUNT_H class SavingsAccoun

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site