Lab 2.2 - Quadratic Formula
The Quadratic Formula is an easy (?) way to calculate the possible
values of x in a quadratic equation. A quadratic equation looks like the
...where a, b, and c are all numbers, and the Quadratic Formula looks something
like the second equation:
Create an application that takes a, b, and c from the user, and
calculates the two possible values of x that make the equation true. Note
that a computer's calculation will have a hard time with the concept of
"plus or minus", so you'll have to split the Formula into two, one with
plus, and one with minus.
Here is a list of objects you'll need:
- A TextBox for the a value.
- A TextBox for the b value.
- Guess what? Yup, a TextBox for the c value.
- Labels for each TextBox so the user knows which box is for which value.
- A GroupBox for a couple of RadioButtons.
- Two RadioButtons, one for the "plus" and one for the "minus"
answers to the Quadratic Formula. The answer for each possibility
should be displayed when each option button is clicked, so each button
will have to be coded with the steps required to calculate the Formula.
- A Label for the answers to appear.
Test your program. Use the following sets of values to test your program:
a = 1, b = 1, c = -6, which should get you 2 and -3
a = 6, b = 11, c = -35, which should be -3.5 and 1.6666666667 (give or take).
Common mistakes include:
- Not setting the TextAlign property to Right in TextBoxes intended for numeric input.
- Not leaving enough space to display the full result.
- Not knowing that raising a number to the power of 0.5 is the same as taking the square root (okay, this isn't really a mistake if you haven't finished Advanced Algebra yet).
- Wasting real estate or cutting off the title of the program.
As always, design a useful and proper interface.