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

C++ Help! PLEASE FOLLOW ALL DIRECTIONS! NEED DONE ASAP! PLEASE INCLUDE COMMENTS

ID: 3750550 • Letter: C

Question

C++ Help! PLEASE FOLLOW ALL DIRECTIONS! NEED DONE ASAP! PLEASE INCLUDE COMMENTS AND SCREENSHOTS!

Question 21

YOU ARE ALLOWED TO USE A COMPILER TO SOLVE PROBLEM:

Define a class Account with the following Specification and attach your solution file(s) when done.

GRADE: Class Interface (30%) , Class Implementation (60%) and working program (10%)


Data Members: (20%)

    private:
        string name; //Name of Account Owner
        string occupation; //Describes Account Owner's Occupation
        double balance; //Account Balance
        double rate; //Account Assigned Rate

___________________________________

Member Functions:(50%)

    public:
        Account(string name="John Doe", string occupation = "Unemployed", double balance=0.0, double rate=0.0);
        void withdraw(double amount); // Withdraws an amount from Account Balance only if amount <= balance
        void deposit(double amount); // Deposits an amount to Account Balance only if amount > 0
        void applyInterest(); // Applies interest to balance at the assigned rate of the Account.
        string getName(); // Return Account Owner Name
        string getOccupation(); // Return Account Owner's Occupation
        double getBalance(); // Return Account Balance
        double getRate(); // Return Account Rate
        void setName(string name);// Assign Account Owner Name
        void setOccupation(string occupation); // Assign Account Owner's Occupation
        void setBalance(double balance); // Assign Account Balance
        void setRate(double rate); // Assign Account Rate;

        void printData(); //Print the content of the data members.

Use the following Driver to test your Class:

// Test Class Definition using the following Driver Program.
int main()
{
    Account acct1, acct2("Susan Francis","Physical Therapist", 93000.0,0.01), acct3("Thomas Thompson","IT Professional",125000.0,0.01);
   
    acct1.withdraw(130000.0);
    acct2.deposit(40000);
    acct3.deposit(4000 );
    acct1.applyInterest();
    acct2.applyInterest();
    acct3.applyInterest();
    acc1.print(); acc2.print(); acc3.print();
    return 0;
}

Explanation / Answer

Program Code:

#include <iostream>

using namespace std;
class Account{
private:
string name; //Name of Account Owner
string occupation; //Describes Account Owner's Occupation
double balance; //Account Balance
double rate; //Account Assigned Rate
public:
//non-parameterized constructor of Account class
Account(){
name="John Doe";
occupation = "Unemployed";
balance=140000.0;
rate=0.0;
}
//parameterized constructor of Account class with all data members
Account(string name, string occupation , double balance , double rate){
this->name=name;
this->occupation=occupation;
this->balance=balance;
this->rate=rate;
}
// Withdraws an amount from Account Balance only if amount <= balance
void withdraw(double amount){
if(amount<=balance){
balance=balance-amount;
}
else{
cout<<"Insufficient balance"<<endl;
}
}
// Deposits an amount to Account Balance only if amount > 0
void deposit(double amount){
if(amount>0){
balance+=amount;
}
else{
cout<<"Amount should be more than Zero"<<endl;
}
}
// Applies interest to balance at the assigned rate of the Account.
void applyInterest(){
if(rate>0.00){
balance+=(balance*rate*1)/(100*12);//Hrer calculating monthly interest
}
else{
balance=balance;
}
}
// Return Account Owner Name
string getName(){
return name;
}
// Return Account Owner's Occupation
string getOccupation(){
return occupation;
}
// Return Account Balance
double getBalance(){
return balance;
}
// Return Account Rate
double getRate(){
return rate;
}
// Assign Account Owner Name
void setName(string name){
this->name=name;
  
}
// Assign Account Owner's Occupation
void setOccupation(string occupation){
this->occupation=occupation;
}
// Assign Account Balance
void setBalance(double balance){
this->balance=balance;
}
// Assign Account Rate;
void setRate(double rate){
this->rate=rate;
}
//Printing the content of the all data members.
void printData(){
cout<<"Account Owner Name : "<<name<<endl<<"Account Owner's Occupation : "<<occupation<<endl<< "Account Balance : "<<balance<<endl<<"Account Rate : "<<rate<<endl;
}
};

int main()
{
//here acct1 is non-parameterized constructor and acct2 or acct3 are parameterized constuctors
Account acct1, acct2("Susan Francis","Physical Therapist", 93000.0,0.01), acct3("Thomas Thompson","IT Professional",125000.0,0.01);

acct1.withdraw(130000.0);
acct2.deposit(40000);
acct3.deposit(4000 );
acct1.applyInterest();
acct2.applyInterest();
acct3.applyInterest();
acct1.printData(); acct2.printData(); acct3.printData();

return 0;
}

Output of Program:

Account Owner Name : John Doe
Account Owner's Occupation : Unemployed
Account Balance : 10000
Account Rate : 0
Account Owner Name : Susan Francis
Account Owner's Occupation : Physical Therapist
Account Balance : 133001
Account Rate : 0.01
Account Owner Name : Thomas Thompson
Account Owner's Occupation : IT Professional
Account Balance : 129001
Account Rate : 0.01

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