Dremendo Tag Line

Input calls and calculate telephone bill in C++

if else if - Question 12

In this question, we will see how to calculate and display the monthly telephone bill along with total numbers of calls and monthly rental in C++ programming using the if else if statement. To know more about if else if statement click on the if else if statement lesson.

Q12) A telephone company charges for using telephone from their consumers according to the calls made (per month) as per the given tariff:

Numbers of calls Charge
Up to 50 calls No charge (free)
For next 100 calls exceeding 50 call Rs. 2 per call
For next 200 calls exceeding 150 call Rs. 1.50 per call + Previous 100 calls bill amount
More than 350 calls Rs. 1 per call + Previous 200 calls bill amount + previous 100 calls bill amount

However, monthly rental charge is Rs.180/- per month for all the consumers for using Telephones. Write a program in C++ to calculate and display the monthly telephone bill along with total numbers of calls and monthly rental.

Program

#include <iostream>
#include <conio.h>

using namespace std;

int main()
{
    int call,mr=180;
    float bill;
    cout<<"Enter total number of calls ";
    cin>>call;

    if(call<=50)
    {
        bill=0;
    }
    else if(call>50 && call<=150)
    {
        bill=(call-50)*2;
    }
    else if(call>150 && call<=350)
    {
        bill=(call-150)*1.5+(100*2);
    }
    else
    {
        bill=(call-350)*1+(200*1.5)+(100*2);
    }

    cout<<"Total Calls = "<<call<<endl;
    cout<<"Total Calls Charges = "<<bill<<endl;
    cout<<"Fixed Monthly Rental = "<<mr<<endl;
    cout<<"Total Bill Amount = "<<bill+mr;
    return 0;
}

Output

Enter total number of calls 243
Total Calls = 243
Total Calls Charges = 339.5
Fixed Monthly Rental = 180
Total Bill Amount = 519.5
video-poster