COSC 1435 Lab 11

Purpose: This lab is to look at ways of using functions & loops.

Due: Before class on April 22, 2013

Requirements: Do the following:

1. Write a program that reads in a length in feet and inches and then converts that input to meters. There are 3.28084 feet in a meters and 12 inches in a foot. This program should use at least three functions. The first function accomplishes the user input. This function should validate (use a while loop) that only legal values are allowed (no negative numbers and or the inch value greater than 12). The second function does the conversion from feet and inches to meters (this function has no input or output statements). This function should return a double value that represents the length in meters as a double value. The third function outputs the results to the console (output is allowed). Make sure that this program works properly before going on to the next requirement. This is an interim program that helps you build to the final solution.

2. Write a second program that converts from meters to feet and inches. This program should use at least three functions. The first function accomplishes the user input and again does validation of the input. The second function does the conversion from meters to feet and inches (this function has no input or output statements). This function should return two values, an integer for the number of feet and a double for the inches value. At least one value must be passed back by reference or you may decide to pass both values back by reference. The third function outputs the results to the console. HINT: Convert the amount in meters to the total number of inches, then convert to feet and inches. Make sure that this program works properly before going on to the next requirement. This is an interim program that helps you build to the final solution.

3. Write a third program that combines the two conversions into a single program. This program should have a menu that allows the user to select which conversion to use (Program 6-10 from Gaddis would be a good starting point) and you should be able to use the functions you wrote for parts 1 & 2 to accomplish major parts of this program. This program should allow the user to enter multiple values to be converted and be able to do conversions either way, by changing the menu selection, without restarting the program. This is the only program you will be submitting to be graded.

4. One of the key focuses of this program is the user interface. Give careful though to the design of the user interface and make sure it is easy to use for a non-class member (think of one of your grandparents). That includes describing what the program does as part of the output.

5. Try your program with a variety of input values (including illegal values), to determine if it works properly.

6. This lab requires a lab report/documentation package. All of these items are not typically in the same file (source code and sample output should definitely be in their own files), but the main lab report file must reference each item by file name. Here is a sample lab report. The main lab report must either be a text file (with a .txt extension) or a Microsoft Word file (with a .doc extension). The lab report must includes the following or references (the file name that was attached to the mail) to the following information:

• Purpose of this program.
• Program source code
• Program output, with sample data. This should include payroll inputs that cause all your validation routines to be checked. You should also verify that your accumulators are working properly.
• How was this program tested, including the test values you put into the program to verify that it worked properly for all types of cases within the program specifications.
• What problems/successes did you have with this program?
• An estimate of how much time you spent working on this lab

Program Submission. You will be submitting this lab via Blackboard. Prepare the following:

• Your program source code. This file should be called lab11***.cpp, where the *** is replaced with your initials.
• A copy of your program output saved as a file. This file should be called lab11***.txt, where the *** is replaced with your initials. The .txt signifies that this is an ASCII text file.
• A lab report as described above. The lab report may be in a Microsoft Word document, with a .doc suffix or an ASCII text file with a .txt suffix. Make sure it contains all of the required items. This file should be called either lab11***doc.txt for a text file or lab11***doc.doc for a Microsoft Word file, where the *** is replaced with your initials.

Submit via blackboard.

Grading Criteria: 100 points available for this lab.
• The lab will be graded using this grading criteria. The points will then be scaled to the available points.
• Here is a C++ style guide from Dr. Fernandez that should assist you in coding your program. Style guide.
• 100 points if all of the above requirements are met.