Answer to Question #222500 in C++ for Jaguar

Question #222500
Consider the class definition below and answer the questions that follow:

class InsurancePolicy
{
public:
InsurancePolicy();
InsurancePolicy(int pNr, string pHolder, double aRate);
~InsurancePolicy();
void setPolicy(int pNr, string pHolder, double aRate);
int get_pNr()const;
string get_pHolder()const;
double get_aRate()const;
private:
int policyNr;
string policyHolder;
double annualRate;
};

(a) Implement the class InsurancePolicy.
1
Expert's answer
2021-08-05T06:54:31-0400


#include<iostream>
using namespace std;
class InsurancePolicy
{
public:


InsurancePolicy(){
    
}


InsurancePolicy(int pNr, string pHolder, double aRate){
    policyNr = pNr;
    policyHolder = pHolder;
    annualRate = aRate;
}


~InsurancePolicy();


void setPolicy(int pNr, string pHolder, double aRate){
    policyNr = pNr;
    policyHolder = pHolder;
    annualRate = aRate;
}


int get_pNr()const{
    return policyNr;
}


string get_pHolder()const{
    return policyHolder;
}


double get_aRate()const{
    return annualRate;
}


private:


int policyNr;


string policyHolder;


double annualRate;


};
InsurancePolicy:: ~InsurancePolicy(void){
    cout<<"Object is being deleted. -Demostrating the calling of the destructor"<<endl;
}


int main(){
    InsurancePolicy policy(1, "John", 12300);
    cout<<"The policy number is\t"<<policy.get_pNr()<<endl;
    cout<<"The policy holder is\t"<<policy.get_pHolder()<<endl;
    cout<<"The policy annul rate is\t"<<policy.get_aRate()<<endl;
   
    
}
  

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS