CS 1405 - Lab 10

Objective

  1. Program with programmer-defined functions

Preparation

  1. Review Chapter 6 from Starting Out with C++ by Gattis.
  2. Print and complete Worksheet 10.

Programming

  1. Write three function definitions and prototypes for functions that will convert English measurements of length to Metric measurements of length.  The first function, inchToCm, converts inches to centimeters (1 inch = 2.54 cm).  The second function, yardToM, converts yards to meters (1 yard = 0.9144 m).  The third function, mileToKm, converts miles to kilometers (1 mile = 1.609344 km).  Be sure to document the functions correctly by including a complete function specification with each definition.
  2. Write a function definition and prototype for a function that gets one floating point value from the user and returns it through a return statement back to the calling function. It should receive the message to use as the prompt through a parameter from the calling function.
  3. Write a function definition and prototype for a function that outputs one floating point value it receives from the calling function to the monitor. It should also receive from the calling function a message to use as a label when outputting the value.
  4. Write a driver program (main function) that puts it all together by using the function in step 2 multiple times to get the number of inches, yards, and miles from the user; using the functions in step 1 to convert those values to centimeters, meters, and kilometers respectively; and using the function in step 3 multiple times to output those converted lengths.
  5. Verify the program works correctly.
  6. Print the Grade Sheet.  Show your program to the instructor.

150 East College Avenue * Ephraim, Utah 84627 * Email: ude.wons@nosneros.htrag
© 2014 Snow College * All Rights Reserved
©