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

See image for program description here: http://i.imgur.com/tLqmK0Q.jpg Thanks In

ID: 3546117 • Letter: S

Question



See image for program description here: http://i.imgur.com/tLqmK0Q.jpg



Thanks

In this problem you have to write class definitions and a main program to simulate different pricing plans for a cellular telephone provider. Suppose you work in the marketing department of the Cellular Two telecommunications company. Your boss wants you to analyze a proposed plan that offers customers a Basic plan and a Premium plan. The Premium plan is designed so that customers who make many calls save money by paying a higher monthly fee. Write class definition for Customer (that represents a basic customer) and for Promium_Customer. Customer should contain data members common to all customers, like the number of calls made in a month, the customers name, and so on. Also implement a virtual member function for computing a bill, Compute_Bill() which uses the appropriate algorithm (mentioned below) 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 allocation in your class. The Premium_Customer class should inherit all attributes of the basic customer, contain data members and initializations specific to its payment plan, and a specific implementation for the Compute_Bill() member function 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? Compute a basic customer's bill as: Bill = monthlyfee + (percall X numcalls) using a monthly fee of $10 and a per call charge of $0.50. Compute a premium customer's bill as: Bill = monthlyfee + (percall X numcalls) + (permin X nummins) using a monthly fee of $20, a per call rate of $0.05. and a per minute call rate of $0.10 Bonus Part (Optional) - 10 points Make this program a simulation to compare the two plans. Make a larger population of customers half of whom use each plan. Vary the number of calls from 10 to 100 (by ten) per month and use a random number generator to pick different numbers of minutes between 2 and 8 for each premium customer. Winch plan is better for most customers in the study? For the customers who do get a savings with the premium plan, what is the average savings? Filename: phoneBill.cpp

Explanation / Answer

#include<iostream>
#include<stdlib.h>
#include<time.h>
#include<string>
using namespace std;
class Customer
{
private:
int no_of_calls_made;
string customer_name;
public:
Customer(string name="",int calls=0)
{
customer_name = name;
no_of_calls_made = calls;
}
string getName()
{
return customer_name;
}
int getNo_of_calls_made()
{
return no_of_calls_made;
}
virtual double Compute_Bill()
{
return (10.00 + no_of_calls_made*0.50);
}
};
class Premium_Customer: public Customer
{
int no_of_minutes;
public:
Premium_Customer(string name="",int calls=0):Customer(name,calls)
{
no_of_minutes = 3;
}
void setNo_of_minutes(int min=3)
{
no_of_minutes = min;
}
double Compute_Bill()
{
return (20.00 + getNo_of_calls_made()*0.05 + getNo_of_calls_made()*no_of_minutes*0.10);
}
};

int main()
{
Customer*     list[6];
srand(time(NULL));
list[0] = new Customer("John Dough",20);
list[1] = new Customer("Bob Dough",50);
list[2] = new Customer("Aswani Dough",60);
list[3] = new Premium_Customer("Kunal Dough",80);
list[4] = new Premium_Customer("Kanwar Dough",100);
list[5] = new Premium_Customer("Kranthi Dough",120);
for(int i=0; i<6; i++)
{
cout << "Customer " << list[i]->getName() << " Owes " << list[i]->Compute_Bill() << " dollars." << endl;
} //end for
for(int i=0; i<6; i++)
{
delete list[i];
}
// this is for BONUS PART of QUESTION.
Customer* new_basic_customer;
Customer* new_premium_customer;
for(int no_of_calls=10; no_of_calls<=100; no_of_calls+=10)
{
new_basic_customer = new Customer("Basic Customer",no_of_calls);
new_premium_customer = new Premium_Customer("Premium Customer",no_of_calls);
// below code returns rand number between 2 and 8.
int rand_minutes = rand()%7+2;
(static_cast<Premium_Customer*> (new_premium_customer))->setNo_of_minutes(rand_minutes);
double basic_customer_bill = new_basic_customer->Compute_Bill();
double premium_customer_bill = new_premium_customer->Compute_Bill();
if(basic_customer_bill > premium_customer_bill)
{
cout << "For Customers with no of calls " << no_of_calls << " is Basic plan is better " << endl;
}
else if(premium_customer_bill > basic_customer_bill)
{
double savings = (premium_customer_bill-basic_customer_bill);
cout << "For Customers with no of calls " << no_of_calls << " is Premium plan is better and their average savings are " << savings << endl;
}
delete new_basic_customer;
delete new_premium_customer;
}


return 0;
}