Table of Contents

Lab 3: Units Conversion Class

Overview

This lab builds on the previous lab. You will refactor your conversion functions into a unit conversion class. Your program will convert between SI and "US" for 3 dimensions: length, volume, and pressure. As before, you will ask the user to choose the conversion, input a measurement, and provide the converted output.

  • Due Tues 6 Nov 2018 at midnight

  • 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")

  • Submission Form

Your class should:

  • Be named Converter

  • Be defined in a separate header file named Converter.h

  • Contain member variables that hold the appropriate unit names (SI and US)

  • Contain exactly one member variable holding the conversion factor.

  • Contain one member function that

    1. Returns void and takes a boolean (the direction of conversion)

    2. Prompts the user for appropriate input, clearly stating the expected units

    3. Outputs the converted input

      1. Use exactly 2 decimal places of precision

      2. Clearly state the output units

Your program should:

  1. Construct one Converter object for each of 3 dimensions: length, volume, and pressure.

    • Each object should be constructed only once in your program (i.e., outside the user input loop)

  2. Prompt the user with numbered menu of available dimensions

    • read and verify user input

  3. Prompt for the direction of conversion (SI to US, US to SI)

    • read and verify user input

  4. Prompt for the measure to be converted

    • Assume the user provides input appropriate for type double.

  5. Perform the appropriate conversion and output the response

  6. Ask the user to quit or continue

    • If continue, proceed to the user menu (Step 3)

Notes

  • You may find the cout.precision() member function useful for generating output.

Required Runs

  • For each dimension, convert one measure from SI to US.

    • Convert the result back to SI.

Grading

Requirement Points

Program runs, correct implementation & output

40

Code formatting and readability

40

Program Output

20

Specifics

  • 15 points: Proper indentation (Formatting)

  • 15 points: Informative comments (Readibility)

  • 5 points: Objects created once (Implementation)

  • 5 points: Appropriate input verification (Implementation)

  • 10 points: Program output should be readable, well-formatted, and correct (Output)