Question

In: Computer Science

Write a discount system for a spa, which provides services and sells products. It offers 3...

Write a discount system for a spa, which provides services and sells products. It offers 3 types of memberships: Premium, Gold and Silver. Premium, gold and silver members receive a discount of 18%, 12%, and 10%, respectively (this might change in future), for all services provided. Customers without membership receive no discount. All members receive a flat 10% discount on products purchased (this might change in future). Your system shall consist of four classes: Customer, Discount, Visit,Product and Services. It shall compute the total bill if a customer purchases $x of products and $y of services, for a visit. Also write a test program to exercise all the services.

Acceptance Criteria

As a user, I should be able to interact with the application interactively.

Note :

  1. Use OOP concepts
  2. Draw class diagram for the above problem
  3. Use any object oriented language(Java/ Python/C++) for program implementation
  4. Give the steps clearly to execute the program at our side

Solutions

Expert Solution

This Problem is implemented in c++

Source Code:

#include <iostream>
using namespace std;
class Customer{
  protected: string name;
            int m;
        Customer(){
            m=0;
        }
        public:
        int membership()    // Function that takes value for Membership
        {
            cout<<"1.Premium\n2.Gold\n3.Silver\n4.Without Member ship\n";
            cout<<"Enter your Membership Number : ";
            cin>>m;
            return m;
        }
  
    
};


class ProductAndService     
 {
  protected : int ch,ch2;
  public:
  
  int product()    // Member Function that calculate the total price of product customer want to buy
  {
      double price = 0;
      while(ch!=4){
      cout<<"\n\n--------------------- PRODUCT LIST -------------------\n";
      cout<<"1.Hair Wax($10)\n2.Shampoo($15)\n3.Face Wash($20)\n----------4.Not Want to Buy----------\n";
      cout<<"Enter Product Number:";
      cin>>ch;
      if(ch==1)price+=10;
      else if(ch==2)price+=15;
      else if(ch==3)price+=20;
      }
    return price;   // Return Product Price
  }
  int service(){    // Member Function that calculate Total service price
      double price = 0;
      while(ch2!=6){
        cout<<"\n\n  ------------------- SERVICE LIST----------------------";
      cout<<"\n1.Hair Cutting($5)\n2.Shave($5)\n3.De-tannng($10)\n4.massage($10)\n5.Facial($20)\n-----------6.Not want to buy-----------";
      cout<<"\nEnter your choice:";
      cin>>ch2;
      if(ch2==1)price+=5;
      if(ch2==2)price+=5;
      if(ch2==3)price+=10;
      if(ch2==4)price+=10;
      if(ch2==5)price+=20;
      }
      
      return price;   // Return Service Price
  }
  
  
    
};
/*  Discount Class Inherits the two class publically  
    one is Customer and
    second is ProductAndService
*/

class Discount : public Customer , public ProductAndService  
{
  protected :
            double mDiscount;   // membership Discount
            double FlatDiscount;  // Flat Discount;
            
    public:
            Discount()
            {
               
                FlatDiscount = 10;
            }
            void checkCustomer()   // Check Customer Membership and add membership discount
            {
              int d;
              d = membership();  //Calls Membership function of class Customer
              switch(d){
                  case 1 : mDiscount = 18; break;
                  case 2 : mDiscount =12; break;
                  case 3: mDiscount = 10; break;
                  case 4: mDiscount =0; break;
                  default : mDiscount = 0;
              }
            }
            void CalculateDiscount()
            {   
                checkCustomer();   // Call checkCustomer method
            
                double ProductBill,ServiceBill;
                ProductBill = product();    // calls product() Function of ProductAndService class which return the bill of products
                ServiceBill  = service();  // calls service() Function of ProductAndService class which returns the bill of services
                double TotalBill;
                
                
                //TotalBill = (ProductBill+ServiceBill)*(FlatDiscount/100)*(mDiscount/100);
                TotalBill = ServiceBill +ProductBill;
                double f,m;
                f=(TotalBill*(FlatDiscount/100));
                m = (TotalBill*(mDiscount/100));
                cout<<"\nTotal Bill is $"<<TotalBill;
                cout<<"\nDiscount : $ "<<f;
                cout<<"\nDiscount(Membership) : $"<<m;
                cout<<"\nBill After Discount : $"<<TotalBill - f-m;
                
            }
             
    
};

class visit : public Discount   // Vist class Inherits the Discount class
{
    public:
        void VisitCustomer()
        {
            cout<<"-------------------  Welcome -------------------";
            cout<<"\nMake Sure you enter Correct Choice otherwise program will be stopped and you need to Re-Execute\n";
            CalculateDiscount();  // Calls CalculateDiscount() Function of Discount class for further activities
        }
};

int main()
{
    
    visit v1;    // Declare object of class visit
    char a;
    while(a!='n')
    {
        v1.VisitCustomer();
        cout<<"\nDo you Want to Continue(y/n)";
        cin>>a;
    }
    
    cout<<"--------------- Thankyou For Coming  ---------------\n\n";
    cout<<"--------------- Visit Again ---------------";
    
    return 0;
}


Output:

.

.

.

.

.

.

.

.

Class Diagram:

.

.

.

If you have any type of error Explain in Comment Section

Thumbs up if you are satisfied.

Thankyou

  

  


Related Solutions

Sabrri Spa offers a variety of skin treatments and spa services, including massages, facials, body treatments,...
Sabrri Spa offers a variety of skin treatments and spa services, including massages, facials, body treatments, and manicures. The spa is owned by the largest dermatology practice in town, and the doctors invested $450,000 to start the spa five years ago. The spa is in its own building next to the clinic, and it has its own staff and management, so almost all of the spa’s costs are direct costs. The average one-hour treatment is priced at $100. Sabrri has...
Bug-Off Exterminators provides pest control services and sells extermination products manufactured by other companies. The following...
Bug-Off Exterminators provides pest control services and sells extermination products manufactured by other companies. The following six-column table contains the company’s unadjusted trial balance as of December 31, 2018. BUG-OFF EXTERMINATORS December 31, 2018 Unadjusted Trial Balance Cash $ 17,600 Accounts receivable 5,300 Allowance for doubtful accounts $ 814 Merchandise inventory 10,200 Trucks 30,500 Accum. depreciation—Trucks 0 Equipment 51,000 Accum. depreciation—Equipment 13,600 Accounts payable 5,100 Estimated warranty liability 1,200 Unearned services revenue 0 Interest payable 0 Long-term notes payable 15,700...
Bug-Off Exterminators provides pest control services and sells extermination products manufactured by other companies. The following...
Bug-Off Exterminators provides pest control services and sells extermination products manufactured by other companies. The following six-column table contains the company’s unadjusted trial balance as of December 31, 2018. BUG-OFF EXTERMINATORS December 31, 2018 Unadjusted Trial Balance Cash $ 15,800 Accounts receivable 4,300 Allowance for doubtful accounts $ 824 Merchandise inventory 11,100 Trucks 30,900 Accum. depreciation—Trucks 0 Equipment 53,000 Accum. depreciation—Equipment 14,000 Accounts payable 4,700 Estimated warranty liability 1,200 Unearned services revenue 0 Interest payable 0 Long-term notes payable 15,000...
Bug-Off Exterminators provides pest control services and sells extermination products manufactured by other companies. The following...
Bug-Off Exterminators provides pest control services and sells extermination products manufactured by other companies. The following six-column table contains the company’s unadjusted trial balance as of December 31, 2018. BUG-OFF EXTERMINATORS December 31, 2018 Unadjusted Trial Balance Cash $ 15,800 Accounts receivable 4,300 Allowance for doubtful accounts $ 824 Merchandise inventory 11,100 Trucks 30,900 Accum. depreciation—Trucks 0 Equipment 53,000 Accum. depreciation—Equipment 14,000 Accounts payable 4,700 Estimated warranty liability 1,200 Unearned services revenue 0 Interest payable 0 Long-term notes payable 15,000...
Bug-Off Exterminators provides pest control services and sells extermination products manufactured by other companies. Following is...
Bug-Off Exterminators provides pest control services and sells extermination products manufactured by other companies. Following is the company's unadjusted trial balance as of December 31, 2019. December 31, 2019 Unadjusted Trial Balance Cash $ 18,600 Accounts receivable 4,800 Allowance for doubtful accounts $ 844 Merchandise inventory 14,100 Trucks 40,000 Accum. depreciation—Trucks 0 Equipment 60,200 Accum. depreciation—Equipment 18,600 Accounts payable 5,400 Estimated warranty liability 1,800 Unearned services revenue 0 Interest payable 0 Long-term notes payable 23,000 Common stock 18,000 Retained earnings...
Bug-Off Exterminators provides pest control services and sells extermination products manufactured by other companies. Following is...
Bug-Off Exterminators provides pest control services and sells extermination products manufactured by other companies. Following is the company's unadjusted trial balance as of December 31, 2019. December 31, 2019 Unadjusted Trial Balance Cash $ 20,000 Accounts receivable 5,500 Allowance for doubtful accounts $ 858 Merchandise inventory 16,200 Trucks 47,000 Accum. depreciation—Trucks 0 Equipment 92,400 Accum. depreciation—Equipment 24,200 Accounts payable 5,750 Estimated warranty liability 2,150 Unearned services revenue 0 Interest payable 0 Long-term notes payable 30,000 Common stock 25,000 Retained earnings...
A country's financial system provides three services to savers and borrowers. One of these services is...
A country's financial system provides three services to savers and borrowers. One of these services is a. the ability of savers to maximize risk. b. the ability of the financial system to buy and sell stocks. c. the ability of savers and borrowers to maintain a sound investment. d. the ability of the financial system to transfer information.
The Giles Agency offers a 8% trade discount when providing advertising services of $1,000 or more...
The Giles Agency offers a 8% trade discount when providing advertising services of $1,000 or more to its customers. Audrey’s Antiques decides to purchase advertising services of $3,000 (not including the trade discount), while Michael’s Motors purchases only $650 of advertising. Both services are provided on account. Record both transactions for The Giles Agency, accounting for any trade discounts. (If no entry is required for a particular transaction/event, select "No Journal Entry Required" in the first account field.) Journal entry...
The Giles Agency offers a 10% trade discount when providing advertising services of $1,000 or more...
The Giles Agency offers a 10% trade discount when providing advertising services of $1,000 or more to its customers. Audrey’s Antiques decides to purchase advertising services of $3,100 (not including the trade discount), while Michael’s Motors purchases only $660 of advertising. Both services are provided on account. Record both transactions for The Giles Agency, accounting for any trade discounts. (If no entry is required for a particular transaction/event, select "No Journal Entry Required" in the first account field.) Record the...
Tempe Office Services and Supplies (TOSS) provides various products and services in the Tempe Research Park,...
Tempe Office Services and Supplies (TOSS) provides various products and services in the Tempe Research Park, home to numerous high-tech and bio-tech companies. Making color copies is one of its most popular and profitable services. The controller performed a regression analysis of data from the Color Copy Department with the following results: Intercept 139.68693 R square 0.9014 Number of observations 6 X coefficient 0.075859 The regression output was based on the following data: Month Number of Color Copies Color Copy...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT