Question: C) Write a program in C++, Create an abstract class Customer with data members name and ID. Provide pure virtual functions discount() and TotalBillAfterDiscount(). Derive

C) Write a program in C++, Create an abstract class Customer with data members name and ID. Provide pure virtual functions discount() and TotalBillAfterDiscount().

Derive a class Loyal Customer from Customer. The class has additional attributes loyaltyLevel and CurrentShoppingBill. The loyalty bill is an integer number between 1 and 20. The loyaltyLevel of a customer is increased after every 10 shoppings from the store. The discount of loyal customer is calculated based on loyalty number and CurrentShoppingBIll, and has the formula discount = loyaltyLevel% X CurrentShoppingBill (if loyaltyLevel =15 then discount = 15% X CurrentShoppingBill).

Derive another class Wandering Customer from Customer. The class has attributes shoppingNumberFromStore and CurrentShoppingBill. The discount is given to Wandering Customer if shoppingNumberFromStore is greater than 5 and CurrentShoppingBill is greater than 1500. If these two conditions are met only then the discount is given otherwise no discount is given. The discount formula for wandering customer is discount = CurrentShoppingBill x (shoppingNumberFromStore/10).

TotalBillAfterDiscount() is computed as CurrentShoppingBill discountedBill for both classes.

Write a program to declare an array of pointers to Customer. Using dynamic memory allocation, create an object of Loyal or Wandering Customer as indicated by the user (Get user choice). Once the user has entered data for Customer, call the discount and TotalBillAfterDiscount method for each object. Write program in C++ and divide in following sections.

//Print Abstract Class here

//Print whole Loyal Customer Class here except discount function definition.

//Print discount function definition of Loyal Customer here function here

//Print whole Wandering Customer Class here except discount function definition.

//Print discount function definition of Wandering Customer here function here

//Print main function here

//Print screenshot showing a scenario when wandering customer cannot get discount

//Print rest of Screenshots here

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!