Hello,
Can any of u help me with this assignment..
I tried to do it myself but cuz I'm new in Object Oriented my program was full of errors that I don't know how to fix :(
Please help me as soon as possible..
here is the question:
Write class definitions for Customer and for a derived class Premium_Customer. Customer should contain data members common to all customers, like the number of calls made in a month, the custom¬er's name, and so on. Also implement a virtual member function for computing a bill, Compute_Bill( ) which uses the appropriate algorithm and data members to compute a monthly charge for each type of customer. In all classes be sure to also include any constructors and other member functions that you think are needed especially if you use dynamic memory al¬location in your class. The derived class should contain data members and initializations spe¬cific to it's payment plan, and a specific implementation for the Compute_Bill() member func¬tion which overrides the default method. Demonstrate programmatically which plan is better for a customer who makes 30 calls per month averaging 3 minutes per call. What about 60 calls?
and my program:
#include <iostream>
#include <string>
using namespace std;
class customer{
public:
string name;
int callNum;
void set_values(string N ,int C){
name=N;
callNum=C;
}
virtual float compute_bill()
{ return (10+(.5 * callNum));}
};
/*customer::customer(string N,int C)
{
name=N;
callNum=C;
}
customer::~ customer()
{
delete N;
delete C;
}
*/
class premium_customer: public customer{
//public:
//premium_customer(string N,int C): customer(N,C){
int x;
cout <<"Please enter the average number of min. per call"<<endl;
cin >> x;
float compute_bill()
{return(20+(.5*callNum)+(.1*x));}
};
int main()
{
customer *list[6];
list[0]=new customer("John Dough",20);
list[1]=new customer("Bob Dough",50);
list[2]=new customer("Jassim Al_Zaid",10);
list[3]=premium_customer("Ghadeer Al_Zaid",50);
list[4]=premium_customer("Anwar Al_Zaid",30);
list[5]=premium_customer("Jane Doe",100);
for (int i=0; i<6; i++){
cout <<"customer "<<list[i]<<"owes "<< list[i].compute_bill()<<"Dollars. "<< endl;
}
/*delete list[0];
delete list[1];
delete list[2];
delete list[3];
delete list[4];
delete list[5];*/
delete [] list;
return 0;
}
Thanks