< previous page page_118 next page >

Page 118
    // Compute miles for each distance on the map

    miles = float(int(DISTANCE1 * SCALE * 10.0 + 0.5)) / 10.0;
    cout < For a measurement of  < setprecision(1) < DISTANCE1
         <  the first distance is  < miles <  mile(s) long.
         < endl;
    totMiles = totMiles + miles;

    miles = float(int(DISTANCE2 * SCALE * 10.0 + 0.5)) / 10.0;
    cout < For a measurement of  < DISTANCE2
         <  the second distance is  < miles <  mile(s) long.
         < endl;
    totMiles = totMiles + miles;

    miles = float(int(DISTANCE3 * SCALE * 10.0 + 0.5)) / 10.0;
    cout < For a measurement of  < DISTANCE3
         <  the third distance is  <miles < mile(s) long.
         < endl;
    totMiles = totMiles + miles;

    miles = float(int(DISTANCE4 * SCALE * 10.0 + 0.5)) / 10.0;
    cout < For a measurement of  < DISTANCE4
         <  the fourth distance is  < miles <  mile(s) long.
         < endl;
    totMiles = totMiles + miles;

    // Print the total miles

    cout < endl;
    cout < Total mileage for the day is  < totMiles <  miles.
         < endl;
    return 0;
}
The output from the program is
For a measurement of 1.5 the first distance is 0.4 mile(s) long.
For a measurement of 2.3 the second distance is 0.6 mile(s) long.
For a measurement of 5.9 the third distance is 1.5 mile(s) long.
For a measurement of 4.0 the fourth distance is 1.0 mile(s) long.

Total mileage for the day is 3.5 miles.

 
< previous page page_118 next page >