Question: I will paste two files, PlusMember.cpp , and PremiumMember.cpp . The CalculateYEarlyFee function in PremiumMember is inheriting from PlusMember. However, in PlusMember, the function calculates

I will paste two files, PlusMember.cpp, and PremiumMember.cpp. The CalculateYEarlyFee function in PremiumMember is inheriting from PlusMember. However, in PlusMember, the function calculates the yearly fee with a discount applied. In PremiumMember, I need it to calculate the yearly fee with the discount and savings_ applied, but I need it to calculate the savings perecentage from the original yearly fee price, not the price with the discount included. EXAMPLE(if YearlyFee is 300,discount_ is 25% and savings_ is 3%, I need the 3% of savings to be calculated from 300, not the 225 which is 300-25%(discount_)). PlusMember.cpp: #include "PlusMember.h"
using namespace std;
PlusMember::PlusMember(const std::string& first_name, const std::string& last_name, const std::string& phone, double fee, double discount)
: BasicMember(first_name, last_name, phone, fee), discount_(discount){}
//Getters
double PlusMember::GetDiscount() const {
return discount_;
}
//Setters
void PlusMember::SetDiscount(double discount){
if (discount <=0.0){
discount_=0.0;
} else {
discount_= discount;
}
}
double PlusMember::CalculateYearlyFee() const {
double yearlyFee = BasicMember::CalculateYearlyFee();
yearlyFee -= yearlyFee * discount_;
return yearlyFee;
}
void PlusMember::Display(std::ostream& os) const {
const int nameWidth =20;
const int phoneWidth =15;
const int feeWidth =10;
const int discountWidth =10;
os << std::setw(nameWidth)<< GetFirstName()+""+ GetLastName()
<< std::setw(phoneWidth)<< GetPhone()
<< std::setw(feeWidth)<< std::fixed << std::setprecision(2)<< GetFee()
<< std::setw(discountWidth)<< std::fixed << std::setprecision(2)<< GetDiscount()<<"%";
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!