Lab 2: Units Conversion
Overview
This lab focuses on writing and using functions. Your program will convert between SI (degrees C, meters, liters) and "US" (degrees F, feet, gallons). You will ask the user to choose the conversion, input a measurement, and provide the converted output.
-
Due Thurs 4 Oct 2018 at midnight
-
If you have not yet done so, please register for a Repl.it account (this can be linked to your Kenyon gmail account, or not).
-
Use a new repl.it C++ template for each problem.
-
-
Collect the the output of the required runs (below) in the editor of your choice (e.g., Office, Google Docs, etc.)
-
Export your document as a pdf (try "Print to PDF")
-
-
Submit your work here:
Your program should:
-
Prompt the user with a menu of 3 numbered options: temperature, length, and volume
-
read (and verify) an integer from user input
-
Prompt for the direction of conversion (SI to US, US to SI)
-
Prompt for the appropriate measure to be converted
-
Perform the appropriate conversion and output the response.
-
Ask the user to quit or continue
-
If continue, proceed to the beginning
-
Notes
-
You may assume that user input is of the appropriate type.
-
Please use a separate function for each dimension (temp, length, volume).
-
Hint: each function should take 2 arguments, including a boolean.
-
-
Please clearly print the appropriate unit(s) for each input and output.
-
Please output 2 significant digits for all numeric output (see below).
-
You may find the
printf
function useful for generating output.
-
Required Runs
-
Convert two different volumes from SI to US.
-
Convert one measurement each (temperature and length) from US to SI.
-
Convert 10 meters to US. Conver your answer back to SI.
-
Do you notice any differences? If so, please explain.
-
Grading
Requirement | Points |
---|---|
Program runs, correct implementation & output |
35 |
Code formatting and readability |
30 |
Program Output & Explanation |
35 |
Specifics
-
10 points: Three defined functions, one per dimension (Runs)
-
10 points: Proper indentation (Formatting)
-
10 points: Informative comments (Readibility)
-
5 points: Define variables in the smallest possible scope (Readability)
-
5 points: Avoid using the same name for more than 1 variable (Readability)
-
10 points: Program output should be readable, well-formatted, and correct (Output)