home *** CD-ROM | disk | FTP | other *** search
- /* This programme is used to calculate the cost of a phone call after the
- user has entered the time of call and duration of call.
-
- Input : Time that call was made, in minutes and seconds
- : Length of call, in minutes and seconds
- : Distance of call, in Kilometers
-
- Output : The cost of the phone call
-
- Constants : The amount charged at a certain time and distance
-
- --------------------------------------------------------------------- */
-
- #include <iostream.h>
- void main ( void )
- {
- int
- TimeScale, DistCalled, DurMin, DurSec, D, N, E, Distance ;
-
- double
- CostPerMin ;
-
- cout << "Enter the time scale used (D/N/E)" ;
- cin >> TimeScale ;
- cout << "Enter the distance called" ;
- cin >> DistCalled ;
- cout << "Enter the duration of the call (Min & Sec" ;
- cin >> DurMin >> DurSec ;
-
- if ((TimeScale = D) && (Distance >745))
- cin >> CostPerMin = 0.55 ;
- else if ((TimeScale = D) && (Distance <745) && (Distance >165))
- cin >> CostPerMin = 0.375 ;
- else if ((TimeScale = D) && (Distance <165) && (Distance >85))
- cin >> CostPerMin = 0.35 ;
- else if ((TimeScale = D) && (Distance <85) && (Distance >25))
- cin >> CostPerMin = 0.15 ;
-
- // The above is if the user called during the DAY time scale
-
-
- if ((TimeScale = N) && (Distance >745))
- cin >> CostPerMin = 0.375 ;
- else if ((TimeScale = N) && (Distance <745) && (Distance >165))
- cin >> CostPerMin = 0.25 ;
- else if ((TimeScale = N) && (Distance <165) && (Distance >85))
- cin >> CostPerMin = 0.25 ;
- else if ((TimeScale = N) && (Distance <85) && (Distance >25))
- cin >> CostPerMin = 0.10 ;
-
- // The above is if the user called during the NIGHT time scale
-
- if ((TimeScale = D) && (Distance >745))
- cin >> CostPerMin = 0.225 ;
- else if ((TimeScale = D) && (Distance <745) && (Distance >165))
- cin >> CostPerMin = 0.15 ;
- else if ((TimeScale = D) && (Distance <165) && (Distance >85))
- cin >> CostPerMin = 0.15 ;
- else if ((TimeScale = D) && (Distance <85) && (Distance >25))
- cin >> CostPerMin = 0.075 ;
-
- // The above is if the user called during the ECONOMY time scale
-
- }
-