Do the following questions from Schneider & Gersting Third Edition:
In this assignment, you will create a program that can represent, solve, and evaluate quadratic
equations of the form:
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
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.
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:
|Submitting your assignment|
For the Theory assignment, print a paper copy and submit it at the beginning of class. You do not need to submit it electronically.
For the Programming assignment, submit a paper copy of all your source code and submit it electronically by the due date. Put all your .java files and your README file in a .zip or .tar file, then follow these instructions:
Remember, only submit your .java files and the README file, not the .class files. If you're using Eclipse, you can find the location of the .java files by right-clicking on the Java project and selecting "Properties...". Then in the Resources window you'll see "Location". That's the location of the project. The .java files should be in the folder called "src".