Answer to Question #174148 in C++ for Raj

Question #174148

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-22T01:59:15-0400
#include <iostream>


using namespace std;


class Tbills{
    int customer_id;
    string customer_name;
    string phone_number;
    int calls;
    float usagecost;
    
    
    public:
    void getCustomerData(int customer_id, string customer_name, string phone_number,int calls){
        this->customer_id = customer_id;
        this->customer_name = customer_name;
        this->phone_number = phone_number;
        this->calls = calls;
    }
    void usageCost(){
        float usage = 0;
        if (this->calls > 0){
            int rate = 200;
            usage += rate;
        }
        if (this->calls > 100){
            int rem = this->calls - 100;
                if(rem > 100){
                    usage += (0.6*50)+(0.5*50)+(0.4*rem);
                }
                else{
                    if (rem < 50){
                        usage += (0.6*rem);
                    }
                    else{
                        usage += (0.6*50)+(0.5*(rem-50));
                    }
                    
                }
        }
        this->usagecost = usage;
    }
    void monthlyTelephoneBills(){
        cout<< "CustomerID: "<< this->customer_id<<"      Customer Name: "<< this->customer_name<<"     Calls: "<<this->calls<<"      Usage: "<<this->usagecost;
    }
};


int main()
{
    Tbills bill;
    bill.getCustomerData(1, "Dann", "0782378472", 201);
    bill.usageCost();
    bill.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