27.07.2015 Views

COMP 122 Lab 5 Lab Report and Source Code (Devry) / comp122dotcom

For more course tutorials visit www.comp122.com COMP 122 Week 5 iLab Objectives Apply structured and modular design principles to write programs that meet written specifications and requirements. Develop a pseudo-code design using appropriate program structure (sequence, selection, repetition and nesting) to solve a given programming problem. Use appropriate selection and repetition statements to implement the design. Create user-defined functions to implement a modular design. Use appropriate parameter passing mechanisms for passing data into and getting data back from functions. Use ostream and iomanip formatting manipulators to display tabulated data. Design and implement a menu-driven interface. Problem Description This program is to give the user the option of converting a set of temperatures either from Celsius to Fahrenheit (C to F) or vice versa, from Fahrenheit to Celsius (F to C), or to quit the program. If the user selects either C to F or F to C, the program will prompt the user to enter three integer values, a starting temperature, an ending temperature, and an increment. After these values have been entered the program will display a table of equivalent C and F (or F and C) temperatures, from the starting temperature to the ending temperature and incrementing by the increment value each row.

For more course tutorials visit
www.comp122.com
COMP 122
Week 5 iLab
Objectives
Apply structured and modular design principles to write programs that meet written specifications and requirements. Develop a pseudo-code design using appropriate program structure (sequence, selection, repetition and nesting) to solve a given programming problem. Use appropriate selection and repetition statements to implement the design. Create user-defined functions to implement a modular design. Use appropriate parameter passing mechanisms for passing data into and getting data back from functions. Use ostream and iomanip formatting manipulators to display tabulated data. Design and implement a menu-driven interface.
Problem Description
This program is to give the user the option of converting a set of temperatures either from Celsius to Fahrenheit (C to F) or vice versa, from Fahrenheit to Celsius (F to C), or to quit the program. If the user selects either C to F or F to C, the program will prompt the user to enter three integer values, a starting temperature, an ending temperature, and an increment. After these values have been entered the program will display a table of equivalent C and F (or F and C) temperatures, from the starting temperature to the ending temperature and incrementing by the increment value each row.

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>COMP</strong> <strong>122</strong> <strong>Lab</strong> 5 <strong>Lab</strong> <strong>Report</strong> <strong>and</strong> <strong>Source</strong> <strong>Code</strong> (<strong>Devry</strong>)<br />

Click Here to Buy the Tutorial<br />

http://www.comp<strong>122</strong>.com/product-25-<strong>COMP</strong>-<strong>122</strong>-<strong>Lab</strong>-5-<strong>Lab</strong>-<strong>Report</strong>-<strong>and</strong>-<br />

<strong>Source</strong>-<strong>Code</strong>-<br />

<strong>COMP</strong> <strong>122</strong><br />

Week 5 i<strong>Lab</strong><br />

Objectives<br />

For more course tutorials visit<br />

www.comp<strong>122</strong><br />

comp<strong>122</strong>.com<br />

Apply structured <strong>and</strong> modular design principles to write programs that meet written<br />

specifications <strong>and</strong> requirements. Develop a pseudo-code design using appropriate program<br />

structure (sequence, selection, repetition <strong>and</strong> nesting) to solve a given programming problem.<br />

Use appropriate selection <strong>and</strong> repetition statements to implement the design. Create userdefined<br />

functions to implement a modular design. Use appropriate parameter passing<br />

mechanisms for passing data into <strong>and</strong> getting data back from functions. Use ostream <strong>and</strong><br />

iomanip formatting manipulators to display tabulated data. Design <strong>and</strong> implement a menudriven<br />

interface.<br />

Problem Description<br />

This program is to give the user the option of converting a set of temperatures either from<br />

Celsius to Fahrenheit (C to F) or vice versa, from Fahrenheit to Celsius (F to C), or to quit the<br />

program. If the user selects either C to F or F to C, the program will prompt the user to enter<br />

three integer values, a starting temperature, an ending temperature, <strong>and</strong> an increment. After<br />

these values have been entered the program will display a table of equivalent C <strong>and</strong> F (or F<br />

<strong>and</strong> C) temperatures, from the starting temperature to the ending temperature <strong>and</strong><br />

incrementing by the increment value each row.<br />

The table must meet all of the following criteria:<br />

The table's column headings should display the degree symbol, e.g., °C <strong>and</strong> °F. The first<br />

column must be the "from" temperature (C for C to F or F for F to C) <strong>and</strong> the second column<br />

the "to" temperature (F for C to F or C for F to C). The calculated "to" temperatures are to be<br />

displayed to the nearest tenth of a degree (display exactly one decimal place, even if there is<br />

no fractional part, i.e., 75° should display as 75.0°). Temperatures in both columns must be<br />

number-aligned (right-justified for the integer "from" values <strong>and</strong> decimal point aligned right<br />

for the "to" values). Assume the user enters correct data, e.g., the start temperature, end<br />

temperature <strong>and</strong> increment are all integers <strong>and</strong> the ending temperature is greater than the<br />

starting temperature.


The formula to convert Celsius to Fahrenheit is<br />

The formula to convert Fahrenheit to Celsius is<br />

Function Requirements<br />

You must create <strong>and</strong> use the following functions:<br />

displayMenu( ) displays a menu. getMenuSelection ( ) gets the menu selection from the user,<br />

upper or lower case 'C' for Celsius to Fahrenheit, upper or lower case 'F' for Fahrenheit to<br />

Celsius, <strong>and</strong> upper or lower case 'Q' to quit. Any other input should get an error message<br />

"Invalid selection: try again" <strong>and</strong> re-prompt for the menu selection.<br />

getStartEndAndIncrement( ) gets the start, end <strong>and</strong> increment values for the table from the<br />

user. CtoF( ) converts a Celsius temperature to Fahrenheit. FtoC( )converts a Fahrenheit<br />

temperatures to Celsius. displayTable( ) displays a C to F or F to C table given start, end <strong>and</strong><br />

increment values <strong>and</strong> the conversion character the user selected.<br />

Additional Requirements<br />

Absolutely NO GLOBAL VARIABLES can be used to implement this program! Any<br />

program using global variables will NOT be accepted! Use a switch statement to respond to<br />

the user's menu selection in the getMenuSelection function. After the user selects a valid<br />

temperature table option, ask the user to enter start, end, <strong>and</strong> increment values, then display<br />

the table <strong>and</strong> stop until the user presses the ENTER key to continue (prompt the user, of<br />

course). When the user presses ENTER to continue the menu should be redisplayed, allowing<br />

the user to make another menu selection (either to display another temperature conversion<br />

table or quit). Make sure that your code is properly formatted (indentation, etc) <strong>and</strong> that you<br />

have provided suitable documentation of all your functions (comment blocks for program <strong>and</strong><br />

functions!).<br />

How to print the degree symbol<br />

It is easy enough to find out how to do this by searching the web. The short answer is:<br />

cout< (char)248;=""><br />

Test Plan<br />

Test cases are generally selected by analyzing the program <strong>and</strong> determining categories of<br />

inputs <strong>and</strong> outputs, then specifying at least one specific input value (or set of input values) for<br />

each category. Inputs for this program include the "selection," or menu input, <strong>and</strong> integer<br />

values to generate a table (start temperature, stop temperature <strong>and</strong> increment value). Here is<br />

an outline of the categories:<br />

Menu test cases should include all possible valid menu selections <strong>and</strong> at least one invalid<br />

menu selection. Table test cases should include<br />

2.1. Inputs that create tables with various numbers of rows


2.2. At least one temperature that calculates to an exact whole number of degrees (e.g., 0<br />

degrees degrees F).<br />

2.3. Negative starting <strong>and</strong> ending temperatures.<br />

2.4. At least one temperature that calculates to a fractional number of degrees (e.g., -50<br />

degrees degrees C).<br />

2.5. Some common, easy to verify conversions, for example<br />

2.5.1. 0 degrees degrees F (<strong>and</strong> vice versa)<br />

2.5.2. 100 degrees degrees F (<strong>and</strong> vice versa)<br />

2.5.3. -40, the only temperature that is the same in both.<br />

Given these categories, use the table on the next page to record the specific input values you<br />

will use for your test plan. Note that you must predict <strong>and</strong> document what the output will be<br />

for each of your test cases, including the calculated values for each row of the temperature<br />

tables produced. Test your program using your selected test cases <strong>and</strong> record the actual<br />

observed output from your test cases by pasting screen shots into your report document.<br />

Make sure everything works correctly before submitting.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!