Lab 3-1

Due: Tue Feb 12, 11:59pm

(extended until Thu Feb 14, 11:59 pm)

payrol

Write a C++ program which does the following (Below is an outline) (150 pts)

repeat
    Print Menu
        1) Compute area of a triangle (according to the formula below)
        2) Compute your clothing size (according to Project 9, in chapter 4 of the textbook)
        3) Convert temperature from Fahrenheit to Celcius (nearest integers)
        4) Convert temperature from Fahrenheit to Celcius (exact values)
        5) Test a positive integer for being prime
        6) Calculate a windchill factor according to the formula from the text, given below.
        7) Quit

    Read Option

    Test Option

        If  1
            Ask the lengts of the sides of the triangle
            If the lengths are acceptable, find and print the area of the triangle (according to the formula below, also see Project 13, Chp 5)
        If  2
            Ask user's height,weight, and age
            Find and compute hat size,jacket size, waist according to formulas in Project 9, page 243 of the textbook
        If 3
            Ask for the temperature in Fahrenheit, as an integer
            Compute the temperature in celcius to nearest integer and print it out
        If 4
            Ask for the temperature in Fahrenheit (exact value)
            Compute the temperature in celcius (exact value) and print it out
        If  5
            Ask for an integer and determine whether it is prime or not.
        If 6
            Ask for a temperature and wind speed to calculate windchill index
        If 7
            Quit the entire program
       Otherwise
            Print "Invalid option"

    End Test

Until user quits

Specifications
1. Use a switch statement to implement the menu
2. Use functions for all subtasks (including printing the menu) . Write comments and pre-and post conditions with function declarations. Tell what each function is supposed to be doing. Separate declarations from definitions.
3. Use the following formula to find the area of the triangle with sides a,b and c (project 13, Chp 5)
    Area= sqrt(s*(s-a)*(s-b)*(s-c)) where s = (a+b+c)/2. So, first ask for the lengths of the sides from the user.
Not every 3 numbers can be sides of a triangle. They must satisfy the triangle inequality: The sum of any two sides must be greater than the third. You should check this condition and give an error message if it is not satisfied.
4. All decimal point number outputs must have 2 digits after the decimal point.
5. Overload the temperature conversion function to implement options 3 and 4. One for option 3 takes an integer argument and return an integer (which is the closest integer temperature). The other one will compute the exact value as a double. So both input and output types will be doubles.
6. You should only accept positive inputs for option 5. Give an error message if the input is negative or 0. 1 is not prime by definition.
7. Use the following formula to compute windchill (given on page 296 of the text)

W = 13.12 + 0.6215 * t - 11.37 * v^0.16 + 0.3965* t * v^0.016

where

You should check if the temperature is not <= 10 and tell the user that the program cannot compute a wind chill above 10 degrees Celsius.

 

Sample output

 

Turn in

 

Grading Table

Requirement

Grading Comments

Score

Code broken up in to functions, each of which performs a single objective.

 

20

 

Good clean, correct, easy to understand Input and output user interface

 

20

 

Complete source code with good formatting, variables names, and comments

 

10

 

Area of a triangle correct solutions

 

20

 

Hat size, jacket size, waist solutions

 

20

 

Fahrenheit to Celsius (Integer) correct solutions

 

15

 

Fahrenheit to Celsius (Exact) correct solutions

 

10

 

Prime Check correct solutions

 

15

 

Wind Chill solutions

 

20

 

Total

 

150