IUP Computer Science
CO 110 Fall '99


Project 2
(Due 1 Oct 99)

Write a complete, well-commented C++ program to solve any quadratic equation.

Hopefully, you remember that a general quadratic equation has the following form: A X2 + B X + C = 0 And if you solved this equation for X, you would find that the two solutions for X are

Your program should prompt the person at the keyboard for the three coefficient values (A, B, and C), then compute the two roots of the equation, and display the results, identifying the roots (one is the "smaller" root, the other is the "larger"). The two roots should each be displayed to three decimal places.

Your program must deal properly with every combination of A, B, and C as floating point values that produce real (not imaginary) roots. That is, the program must work as long as B2 - 4AC is greater than or equal to zero; however, the program is NOT expected to verify that this is the case. You should test the program with a wide variety of data - part of the grading will be based on how robust your program is.

Hand in a printout of your program and a printout from the results windows when the following coefficients are entered: 20.3 for A, 105.56 for B, and -499.38 for C. Print the program using the development environment.

There are several ways you may need to try to print the results. One way to print is with the "Print Screen" key - Hold down the shift key and press Print Screen; this may not output because there is no form feed at the end of the results window. Or you may copy the entire window to the clipboard (hold down Alt and press Print Screen) and paste it into a document, such as an MS Word document and print. Or mark and copy the contents of the window to the clipboard, then paste it into a wordprocessor document (even Note Pad can accept this) and print.