Answer to Question #20523 in C++ for aman

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.
1
Expert's answer
2013-01-08T12:06:10-0500
#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();
}

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
APPROVED BY CLIENTS