Lab 3: Due 11:59 pm, Feb 13
Write a C++ program which does the following (Below is an outline) (60 pts)
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 in Programming Project 14 (page 300-1) of the textbook (though I am not convinced that it is the best formula available).
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)
Ask user's height,weight, and age
Find and compute hat size,jacket size, waist according to formulas in Project 9, page 246 of the textbook
Ask for the temperature in Fahrenheit, as an integer
Compute the temperature in celcius to nearest integer and print it out
Ask for the temperature in Fahrenheit (exact value)
Compute the temperature in celcius (exact value) and print it out
Ask for an integer and determine whether it is prime or not.
Ask for a temperature and wind speed to calculate windchill index
Quit the entire program
Print "Invalid option"
Until user quits
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. Make sure the restriction on the temperature is not violated. Use the "assert" Macro to achieve this (or better, use the alternative version we learned in class)
8. There is no universially accepted formula for the windchill factor. You may compare your answers againts some web pages that do calculate that value but keep in mind that i) the units are different ii) the formulas are probably different. Here are couple of sites that caculate windchill effect: