

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Class: SI Object-Oriented Programming; Subject: Computer Science; University: Weber State University; Term: Unknown 2008;
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Page 1 of 2
Quadratic equations have the form: ax 2 + bx + c = 0 where a (cannot be 0), b, and c are the coefficients and x is the unknown value. x is computed using the quadratic formula:
There are some complex issues (a poor pun BTW) that must be dealt with but these are best left until the next chapter. The ± operation leads to two similar calculations: replace ‘±’ with ‘+’ in the first calculation and with ‘-’ in the second. The two calculations produce two roots or solutions to the original equation.
The math library includes a function named sqrt to calculate square roots. Any program that uses this function must include the math header file (the library is linked automatically). #include
... y = sqrt(x); Note that x in the above function may be a constant, a variable, or an expression.
Write a program named roots.cpp that:
Write a program named cone.cpp that:
1 3
2 π
2 2 2
The math header file
You may use the pow function (included in the math library and demonstrated in class) to square the values in the above formulas; however, for squares and cubes, it’s just about as easy to multiply the numbers by themselves: radius * radius.
Page 2 of 2
Program Submission and Grading
Both programs should exhibit good programming style. Specifically, use consistent and appropriate indentation and blank lines (put blank lines where they improve readability but eliminate irrelevant blank lines).
The file grade1.bat is the test bed used to grade this assignment. You may also use it to verify that you programs are correct prior to submission.
Upload roots.cpp and cone.cpp to WSU Online for grading.