Write a C++ program which does the following (Below is an outline)
repeat
Print Menu
1) Compute area of a triangle
2) Compute area of a circle
3) Find the roots of a quadtratic equation
4) Test a number for being prime
5) Calculate a windchill factor according to the formula in Programming Project 14 (page 296-7) of the textbook (though I am not convinced that it is the best formula available).
6) 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)
If 2
Ask the radius of a circle
Find and print the area
If 3
Ask for the coeffients a,b,c of
a quadratic equation a*x^2+b*x+c = 0
Find and print out the real roots, if any
If 4
Ask for an integer and determine whether it
is prime or not.
If 5
Ask for values of wind speed in m/sec and temperature in degrees Celcius (but temperature must be at most 10 degrees). The programs should report the value of the windchill factor.
If 6
Quit the entire program
Otherwise
Print "Invalid option"
End Test
Until user quits
Your Program must satisfy the following requirements
0. All the values you get from user are real numbers (i.e. double or float) except for option 4.
1. Use functions for all subtasks (including printing the menu)
2. Use a switch statement to implement the menu
3. Note that some the functions you need may not return a single value (you may actually write all the functions as void functions)
4. Use the following formula to find the area of the triangle with sides a,b and c.
Area= sqrt(s*(s-a)*(s-b)*(s-c)) where s = (a+b+c)/2.
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.
5. Declare PI as a global double constant (take PI=3.14) and all the numbers output must have 2 digits after the decimal point. Also use the "pow" function from the <cmath> library to compute squares.
6. If a = 0, a*x^2+b*x+c = 0 is not a quadratic equation.
Given a quadratic equation a*x^2+b*x+c = 0, it may or may not have solutions in real numbers.
If a = 0, it is not a quadratic equation at all.
You determine this by looking at the discriminant D = b^2-4*a*c.
If D<0 then no real solutions
If D = 0 there is only one solution
If D>0 then there are 2 distinct real solutions.
You should be able to handle all the cases and print out appropriate messages.
(So your functions does not return a single value)
In case D>0 the two real solutions are (-b+sqrt(D))/(2*a) and (-b-sqrt(D))/(2*a)
If D=0, the only solution is -b/(2*a)
7. Any integer less than 2 (negative numbers, 0 and 1) is a non-prime. You should accept negative inputs for option
4 (negative numbers are not prime).
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: