Objective
- Program with programmer-defined functions
Preparation
- Review Chapter 6 from Starting Out with C++ by Gattis.
- Print and complete Worksheet 10.
Programming
- 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.
- 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.
- 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.
- 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.
- Verify the program works correctly.
- Print the Grade Sheet. Show your program to the instructor.
|