# Homework #2

### Due 5:30pm Mon Jun 8

 Theory Do the following questions from Schneider & Gersting Third Edition: Chapter 3: 10, 11, 19, 25, 28 PLEASE NOTE!!! For question 10, the first sentence should be "... are performed on a list of six elements that is already sorted in the reverse order".

 Programming In this assignment, you will create a program that can represent, solve, and evaluate quadratic equations of the form: `y = ax2 + bx + c`. First, create a class called QuadraticEquation. It should have three attributes to hold the values of a, b, and c; these should have appropriate accessor methods. It should also have a constructor that allows for the initialization of these values. And it should have a method "evaluate" which takes as its input the value of x and returns the value of the quadratic formula. Next, create a class called QuadraticEquationSolver. This class should have a QuadraticEquation as one of its attributes; this should be set via a parameter to the constructor, but you should also have a mutator method to set this attribute, too. The class should also have attributes "solution1" and "solution2" (remember, a quadratic equation can have two solutions) and corresponding accessor methods. Last, create a method called "solve" that solves the quadratic equation `ax2 + bx + c = 0`. The method should set the values of "solution1" and "solution2" appropriately. NOTE: you may assume that the values of a, b, and c are such that a real solution can be calculated. Just be sure to choose a sufficiently big value of b when you do your testing. If you try to take the square root of a negative number, the program may crash or produce unexpected results; that's okay at this point, but we'll see how to deal with that soon. Last, create a class called QuadraticEquationTest that prompts the user to enter values for a, b, and c and then creates a QuadraticEquation. It should then ask the user for a value of x, evaluate the formula, and print out the result. Then it should use the QuadraticEquationSolver to find the equation's (real) solutions and print those out to the screen. HINT: You should be using Scanner and System.out.println only in the QuadraticEquationTest class, and not in the other two. Try to separate the "concept" of a quadratic equation and its solver from the "user interface" of a program that uses those classes. Please be sure to include a "README" file with your submission. For this assignment, it should be about two paragraphs long. You should explain how your program works, how to run it, what the output means, and how you performed all of the calculations.

 Grading The Theory part is worth 50 points total. Each question is worth 10 points. The Programming part is worth a total of 50 points, distributed as follows: Your program must compile with no errors (5 points) Your program must implement the classes and the corresponding methods described above (5 points) The program should produce the correct results for evaluating and solving the quadratic equation, assuming that real solutions exist (30 points) Your program should include a README file, be well-commented, use good variable names, be easy to read, etc. (10 points)