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

Write a class called CustomerProject. It should have three double fields called

ID: 3763510 • Letter: W

Question

Write a class called CustomerProject. It should have three double fields called hours (the number of hours the project took), materials (the cost of materials) and transportation (transportation costs), in that order. It should have get and set methods for each field. It should have a constructor that takes as parameters the values for each field and calls the set methods to initialize them. It should have a pure virtual function called billAmount that takes no parameters and returns a double.

Write two classes that inherit from CustomerProject: RegularProject and PreferredProject. Both should have a constructor that takes three doubles and passes them to the base class constructor. RegularProject should override billAmount to return the sum of the materials costs, the transportation costs, and $80 times the number of hours. PreferredProject (for preferred customers) should override billAmount to return the sum of 85% of the materials costs, 90% of the transportation costs, and $80 times the number of hours up to a maximum of 100 hours (any hours beyond 100 are free).

Hint: You can access the member data of the base class either of two ways:

1) make that member data protected in the base class

or 2) simply use the get methods, which the derived classes have inherited.

The files must be called: CustomerProject.hpp, CustomerProject.cpp, RegularProject.hpp, RegularProject.cpp, PreferredProject.hpp, and PreferredProject.cpp.

Explanation / Answer

// Please note you can save all the related class in seperate files and save them using your naming conventions and store them in same path directory.

#include <cstdlib>
#include <iostream>

using namespace std;

class CustomerProject
{
public:
    double hours;
    double materialsCost;
    double transportationCost;
    double getHours()
    {
         
           return hours;
    }
    
    double getmaterialsCost()
    {
         
           return materialsCost;
    }
    double gettransportationCost()
    {
         
           return transportationCost;
    }  
    
   void sethours(double h)
   {
      
    hours=h;  
      
   }
    
   void setmaterialsCost(double mc)
   {
      
    materialsCost=mc;  
      
   }    
    
    void settransportationCost(double tc)
   {
      
    transportationCost=tc;  
      
   }   
CustomerProject(double h,double mc,double tc)
{
     sethours(h) ;         
      setmaterialsCost(mc);
      settransportationCost(tc);         
}


virtual double billAmount() = 0;
    
      };

class RegularProject :public CustomerProject
{ public:
RegularProject(double h,double mc,double tc) : CustomerProject(h,mc,tc)
{
               
                     
}
double billAmount()

{
   return (getmaterialsCost()+gettransportationCost()+80*getHours()) ;    
        
}
      

};

class PreferredProject :public CustomerProject
{ public:
PreferredProject(double h,double mc,double tc) :CustomerProject(h,mc,tc)
{
                    
                     
}
double billAmount()

{ if(hours<=100)
   return ((85*getmaterialsCost())/100+(90*gettransportationCost())/100+80*getHours()) ;    
     else
      return ((85*getmaterialsCost())/100+(90*gettransportationCost())/100+80*100) ;
}
      

};

int main(int argc, char *argv[])
{
    PreferredProject pp(10,10,10);
   RegularProject rp(10,10,10);
   cout<<"The bill amount for Regular Customer "<<rp.billAmount()<<endl;
  
    cout<<"The bill amount for Prefered Customer "<<pp.billAmount()<<endl;
  
  
  
  
    system("PAUSE");
    return EXIT_SUCCESS ;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote