Design a class TBills to include customer_id, customer_name, phone number, calls and usagecost and also include the following member functions
-getCustomerData()- To input customer data(customer_id, customer_name, phone number,calls)
-usage_cost() -Â to calculate the monthly telephone bills and calculate the usage cost of telephone bill as per the following rule:
• Minimum Rs. 200 for upto 100 calls.
• Plus Rs. 0.60 per call for next 50 calls.
• Plus Rs. 0.50 per call for next 50 calls.
• Plus Rs. 0.40 per call for any call beyond 200 calls.
#include <iostream>
#include <string>
using namespace std;
class TBills
{
private:
int customer_id;
string customer_name;
string phone_number;
int calls;
public:
void getCustomerData(int id, string name, string number,int calls){
this->customer_id=id;
this->customer_name=name;
this->phone_number=number;
this->calls=calls;
}
double usage_cost(){
int number_calls=calls;
if (number_calls <= 100)
{
return 200;
}
else if (number_calls > 100 && number_calls <= 150)
{
number_calls = number_calls - 100;
return 200+(0.60 *number_calls);
}
else if (number_calls > 150 && number_calls <= 200)
{
number_calls = number_calls - 150;
return 200+(0.60 *50) + (0.50 *number_calls);
}
else
{
number_calls = number_calls - 200;
return 200 + (0.60 * 50) + (0.50 * 50) + (0.40 * number_calls);
}
}
void printTBill(){
cout << "The customer ID is: " << customer_id << endl;
cout << "The customer name is: " << customer_name << endl;
cout << "The customer phone number is: " << phone_number << endl;
cout << "The customer calls is: " << calls << endl;
cout << "The customer payment is: " << usage_cost() << endl<< endl;
}
};
int main (){
TBills TBillsPeter;
TBillsPeter.getCustomerData(1,"Peter","055625369",50);
TBillsPeter.printTBill();
TBills TBillsMike;
TBillsMike.getCustomerData(2,"Mike","044856985",150);
TBillsMike.printTBill();
TBills TBillsMary;
TBillsMary.getCustomerData(3,"Mary","0451316113",350);
TBillsMary.printTBill();
system("pause");
return 0;
}
Comments
Leave a comment