Question #20523

ask the user to input telephone bill. You have to find out total bill according to following conditions.
The first 30 calls charge no rupees. The next 20 call charge Rs.2 per call. The next 30 calls charge Rs.3 per call. And next calls charge Rs.5 per call.

Expert's answer

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

using namespace std;

void main()
{
int callCount;
int totalBill = 0;

cout << "Enter a number of calls: ";
cin >> callCount;

if (callCount > 30)
callCount -= 30;
else
callCount = 0;

if (callCount > 20)
{
totalBill += 40;
callCount -= 20;
}
else
{
totalBill += callCount * 2;
callCount = 0;
}

if (callCount > 30)
{
totalBill += 90;
callCount -= 30;
}
else
{
totalBill += callCount * 3;
callCount = 0;
}

totalBill += callCount * 5;

cout << "The total bill is: " << totalBill;
getch();
}
LATEST TUTORIALS
APPROVED BY CLIENTS