Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

=+What kind of study is this?

Answered: 1 week ago

Question

What products or services does your key public commonly use?

Answered: 1 week ago

Question

What position do you seek?

Answered: 1 week ago