Answer to Question #175181 in C++ for Pradeepraj

Question #175181

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-24T17:12:51-0400
class TBills
{
public:
   int customer_id,calls;
   unsigned long long int phone_no;
   float usagecost;
   string customer_name;


   void getCustomerData()
   {
       cout<<"Enter Customer ID ";
       cin>>customer_id;
       cout<<"\nEnter Customer Name ";
       cin>>customer_name;
       cout<<"\nEnter Phone Number ";
       cin>>phone_no;
       cout<<"\nEnter number of calls ";
       cin>>calls;
   }


   float usage_cost(int n)
   {
       if(n<=100)
       {
           usagecost=200;
           return usagecost;
       }
       if(n>100 && n<=200)
       {
           int s;
           s=n%100;
           if(s<=50)
           {
               usagecost=(s*0.60)+200;
               return usagecost;
           }
           else
           {
               int t;
               t=s-50;
               usagecost=(t*0.50)+230;
               return usagecost;
           }
       }
       else
       {
           int v;
           v=n%200;
           usagecost=(v*0.40)+255;
           return usagecost;
       }
   }
   void monthlyTelephoneBills()
   {
       long monthly_bill;
       monthly_bill=usage_cost(calls);
       cout<<"\nMonthly Bill = "<<monthly_bill;
   }
};

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