home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15000 / ass1.cpp
Encoding:
C/C++ Source or Header  |  1996-08-05  |  2.1 KB  |  65 lines

  1. /* This programme is used to calculate the cost of a phone call after the
  2. user has entered the time of call and duration of call.
  3.  
  4. Input         : Time that call was made,  in minutes and seconds
  5.                 : Length of call,  in minutes and seconds
  6.                 : Distance of call,  in Kilometers
  7.  
  8. Output        : The cost of the phone call
  9.  
  10. Constants     : The amount charged at a certain time and distance
  11.  
  12. --------------------------------------------------------------------- */
  13.  
  14. #include <iostream.h>
  15. void main ( void )
  16. {
  17.     int
  18.         TimeScale, DistCalled, DurMin, DurSec, D, N, E, Distance ;
  19.  
  20.     double
  21.         CostPerMin ;
  22.  
  23.     cout << "Enter the time scale used (D/N/E)" ;
  24.     cin >> TimeScale ;
  25.     cout << "Enter the distance called" ;
  26.     cin >> DistCalled ;
  27.     cout << "Enter the duration of the call (Min & Sec" ;
  28.     cin >> DurMin >> DurSec ;
  29.  
  30.     if ((TimeScale = D) && (Distance >745))
  31.         cin >> CostPerMin = 0.55 ;
  32.     else if ((TimeScale = D) && (Distance <745) && (Distance >165))
  33.         cin >> CostPerMin = 0.375 ;
  34.     else if ((TimeScale = D) && (Distance <165) && (Distance >85))
  35.         cin >> CostPerMin = 0.35 ;
  36.     else if ((TimeScale = D) && (Distance <85) && (Distance >25))
  37.         cin >> CostPerMin = 0.15 ;
  38.  
  39. // The above is if the user called during the DAY time scale
  40.  
  41.  
  42.     if ((TimeScale = N) && (Distance >745))
  43.         cin >> CostPerMin = 0.375 ;
  44.     else if ((TimeScale = N) && (Distance <745) && (Distance >165))
  45.         cin >> CostPerMin = 0.25 ;
  46.     else if ((TimeScale = N) && (Distance <165) && (Distance >85))
  47.         cin >> CostPerMin = 0.25 ;
  48.     else if ((TimeScale = N) && (Distance <85) && (Distance >25))
  49.         cin >> CostPerMin = 0.10 ;
  50.  
  51. // The above is if the user called during the NIGHT time scale
  52.  
  53.     if ((TimeScale = D) && (Distance >745))
  54.         cin >> CostPerMin = 0.225 ;
  55.     else if ((TimeScale = D) && (Distance <745) && (Distance >165))
  56.         cin >> CostPerMin = 0.15 ;
  57.     else if ((TimeScale = D) && (Distance <165) && (Distance >85))
  58.         cin >> CostPerMin = 0.15 ;
  59.     else if ((TimeScale = D) && (Distance <85) && (Distance >25))
  60.         cin >> CostPerMin = 0.075 ;
  61.  
  62. // The above is if the user called during the ECONOMY time scale
  63.  
  64. }
  65.