Suppose you are purchasing something online on the Internet. At the website, you get a 10% discount if you are a member. Additionally, you are also getting a discount of 5% on the item because its Father's Day. Write a function that takes as input the cost of the item that you are purchasing and a Boolean variable indicating whether you are a member (or not), applies the discounts appropriately, and returns the final discounted value of the item. Note: The cost of the item need not be an integer

Respuesta :

Answer:

The function is written in C++

void calc_discount(double amount,bool member)

{

 double discount;

 if(member)

 {

  discount = amount - 0.10 * amount - 0.05 * amount;

 }

 else

 {

  discount = amount - 0.05 * amount;

 }

 cout<<"Discount = "<<discount;

}

Explanation:

I've included the full source code (including the main method) as an attachment where I use comments as explanations

Ver imagen MrRoyal