1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
//almost got this code working the output shows a floating number on array //Kacey,John,and carrot and should be a two digit number
//
#include<iostream>
#include<string>
using namespace std;
class Customer
{
protected:
string name;
int numCalls;
public:
Customer(string N, int c);
virtual ~Customer();
void set_values(string N, int C)
{
name = N;
numCalls = C;
}
string getName()
{
return name;
}
virtual float Compute_Bill()
{
return (10 + (.5 * numCalls));
}
};
class Premium:public Customer
{
protected:
public:
int x;
Premium(string N, int C):Customer (N,C)
{
name = N;
numCalls = C;
}
virtual ~Premium();
}
float Compute_Bill()
{
return (20 + (.5 * numCalls) + (.1 * x));
}
};
Customer::Customer(string N, int C)
{
name = N;
numCalls = C;
}
Customer::~Customer(){}
Premium::~Premium(){}
int main()
{
const int NUM_PEOPLE = 6;
Customer *arr[NUM_PEOPLE] =
{
new Premium("Indiana Jones", 20),
new Customer("James Kirt", 50),
new Premium("Kacey Musgraves", 10),
new Premium("John Stewart", 50),
new Customer("Kaley Cuoco", 30),
new Premium("Carrot Sticks", 100)
};
for(int k = 0; k < NUM_PEOPLE;k++)
{
cout<<" Customer "<< arr[k]->getName()<< " owes " <<arr[k]->Compute_Bill()<<
" Dollars. "<<endl;
}
for(int k = 0; k < NUM_PEOPLE; k++)
{
delete arr[k];
}
return 1;
}
|