C++ Programming : Program 26-A
Program to enter the unit reading and output the customer's telephone bill
#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.
250
You have used 250 units. Your total bill is $125
|
45 more pages in C++ Programming