Sample – Program to enter the unit reading and output the customer’s telephone bill.

by Nideesh C on February 8, 2011 · 0 comments

in C++




#include <iostream.h>
#include <conio.h>
int main()
{
clrscr();
long int units,charge=0;
float total;
const int rent=25;
cout << “Enter the number of units used : “;
cin>>units;
if(units>200)
charge=(units-200)*20+150*40+50*60;
else if(units>50)
charge=(units-50)*40+50*60;
else
charge=units*60;
total=0.01*charge+rent;
cout << “You have used ” << units << ” units.” << endl;
cout << “Your total telephone bill is $” << total;
getch();
return 0;
}

This program takes in the number of units used (‘units’) as a screen input from the user.
It then calculates the total telephone bill for the customer on the following basis :
A compulsory fee of $25, plus
60 cents per unit for the first 50 units,
40 cents per unit for the next 150 units,
20 cents per unit for anything above 200 units.
It then outputs the bill using the ‘cout’ command.

Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. Sample – Program to enter an integer and output its 15 multiples.
  2. Sample – Program to enter three integers and output the biggest integer.
  3. Sample – Program to enter three integers and output the biggest integer using IF
  4. Sample – Program to enter an integer and output the cube of that integer.
  5. Sample – Program to enter an integer and print out its successor.

Leave a Comment

Previous post:

Next post: