Answer to Question #172502 in C++ for Rahul

Question #172502

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.



-monthlyTelephoneBills() - to display monthly telephone bills of customer


1
Expert's answer
2021-03-20T19:39:12-0400
#include <iostream>
#include <string>
 
using namespace std;
 
class TBills
{
public:
	void getCustomerData(int id, string name, string number,int calls);
	double usage_cost();
	void monthlyTelephoneBills();
private:
	int customer_id;
	string customer_name;
	string phone_number;
	int callsand;
};
 
void TBills::getCustomerData(int id, string name, string number, int calls)
{
	customer_id = id;
	customer_name = name;
	phone_number = number;
	callsand = calls;
}
 
double TBills::usage_cost()
{
	if (callsand <= 100)
		return 200;
	if (callsand <= 150)
		return 200 + (callsand - 100) * 0.6;
	if (callsand <= 200)
		return 200 + 50 * 0.6 + (callsand - 150) * 0.5;
	if (callsand > 200)
		return 200 + 50 * 0.6 + 50 * 0.5 + (callsand - 200) * 0.4;
}
 
void TBills::monthlyTelephoneBills()
{
	cout << "*****BILL*****" << endl;
	cout << "Castomer ID is: " << customer_id << endl;
	cout << "Customer name is: " << customer_name << endl;
	cout << "Customer phone number is: " << phone_number << endl;
	cout << "Customer callsand is: " << callsand << endl;
	cout << "Customer payment is: RS" << usage_cost() << endl;
	cout << "**************" << endl;
}
 
int main()
{
	TBills Mak;
	Mak.getCustomerData(165875, "Brian Silva", "(025) 365-6598", 1000);
	Mak.monthlyTelephoneBills();
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS