Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PreferredCustomer Class A retail store has a preferred customer plan where custo

ID: 3690240 • Letter: P

Question

PreferredCustomer Class
A retail store has a preferred customer plan where customers may earn discounts on all
their purchases. The amount of a customer’s discount is determined by the amount of
the customer’s cumulative purchases in the store.
• When a preferred customer spends $500, he or she gets a 5% discount on all future
purchases.
• When a preferred customer spends $1,000, he or she gets a 6% discount on all
future purchases.
• When a preferred customer spends $1,500, he or she gets a 7% discount on all
future purchases.
• When a preferred customer spends $2,000 or more, he or she gets a 10% discount
on all future purchases.
Design a class named PreferredCustomer , which is derived from the CustomerData
class you created in Programming Challenge 7. The PreferredCustomer class should
have the following member variables:
• purchasesAmount (a double )
• discountLevel (a double )
The purchasesAmount variable holds the total of a customer’s purchases to date. The
discountLevel variable should be set to the correct discount percentage, according to
the store’s preferred customer plan. Write appropriate member functions for this class
and demonstrate it in a simple program.
Input Validation: Do not accept negative values for any sales figures.

C++?

Explanation / Answer

//Calculating Discount Amount

class PreferredCustomer:public CustomerData{

    public :

        double purchaseAmount;

        double discontLevel;

      double totalAmount;    

        void calPurchaseAmount(){

            cout<<"Enter purchase Amount";

            cin>>purchaseAmount;

        }

        void calDiscountAmount(){

            if (purchaseAmount ==1000){

                discountLevel = 6/100;

                totalAmount = purchaseAmount -(purchaseAmount*discountLevel);

                cout<<"totalAmount of when Customer spend 1000"<<totalAmount;

            }

            else if (purchaseAmount ==500){

                discountLevel = 5/100;

                totalAmount = purchaseAmount -(purchaseAmount*discountLevel);

                cout<<"totalAmount of when Customer spend 500"<<totalAmount;

            }

            else if (purchaseAmount ==1500){

                discountLevel = 7/100;

                totalAmount = purchaseAmount -(purchaseAmount*discountLevel);

                cout<<"totalAmount of when Customer spend 1500"<<totalAmount;

            }

            else if (purchaseAmount ==2000){

                discountLevel = 10/100;

                totalAmount = purchaseAmount -(purchaseAmount*discountLevel);

                cout<<"totalAmount of when Customer spend 2000"<<totalAmount;

            }

            }

    };

int main(){

    PreferredCustomer pCust;

   //accessing purchaseamount

    pCust.calPurchaseAmount();

    //calculate discount amount

    pCust.calDiscountAmount();

    return 0;

}