home *** CD-ROM | disk | FTP | other *** search
/ Share Gallery 1 / share_gal_1.zip / share_gal_1 / ED / ED003A.ZIP / ANSWERS / CH07_3C.CPP < prev    next >
Text File  |  1990-07-20  |  2KB  |  60 lines

  1.                               // Chapter 7 - Programming exercise 1
  2. #include "iostream.h"
  3. #include "vehicle.hpp"
  4. #include "car.hpp"
  5. #include "truck.hpp"
  6.  
  7.  
  8. main()
  9. {
  10. vehicle unicycle;
  11.  
  12.    unicycle.initialize(1, 12.5);
  13.    cout << "The unicycle has " << 
  14.                                 unicycle.get_wheels() << " wheel.\n";
  15.    cout << "The unicycle's wheel loading is " << 
  16.          unicycle.wheel_loading() << " pounds on the single tire.\n";
  17.    cout << "The unicycle weighs " << 
  18.                              unicycle.get_weight() << " pounds.\n\n";
  19.  
  20. car sedan;
  21.  
  22.    sedan.initialize(4, 3500.0, 5);
  23.    cout << "The sedan carries " << sedan.passengers() << 
  24.                                                     " passengers.\n";
  25.    cout << "The sedan weighs " << sedan.get_weight() << " pounds.\n";
  26.    cout << "The sedan's wheel loading is " << 
  27.                     sedan.wheel_loading() << " pounds per tire.\n\n";
  28.  
  29. truck semi;
  30.  
  31.    semi.initialize(18, 12500.0);
  32.    semi.init_truck(1, 33675.0);
  33.    cout << "The semi weighs " << semi.get_weight() << " pounds.\n";
  34.    cout << "The semi's efficiency is " << 
  35.                           100.0 * semi.efficiency() << " percent.\n";
  36.    cout << "The trucks total weight is " << semi.total_weight()
  37.                                          <<  " pounds.\n";
  38. }
  39.  
  40.  
  41.  
  42.  
  43. // Result of execution
  44. //
  45. // The unicycle has 1 wheel.
  46. // The unicycle's wheel loading is 12.5 pounds on the single tire.
  47. // The unicycle weighs 12.5 pounds.
  48. //
  49. // The bicycle has 2 wheels.
  50. // The bicycle's wheel loading is 19 pounds per tire.
  51. // The bicycle weighs 38 pounds.
  52. //
  53. // The sedan carries 5 passengers.
  54. // The sedan weighs 3500 pounds.
  55. // The sedan's wheel loading is 875 pounds per tire.
  56. //
  57. // The semi weighs 12500 pounds.
  58. // The semi's efficiency is 72.929072 percent.
  59. // The trucks total weight is 46175 pounds.
  60.