Hi again from the most programming challenged person in the world... I really appreciated al your help before. I had hoped to not need to ask for help again,yet here I am, asking for help, and saying THANKS! for before and inadvance for help here too =]
I have a question which I cannot even understand no matter how many times I read it; I am worse at one thing than
JAVA, and that is Algebra.... I am posting the problem, and then the code I have for it so far. It did complie, once, and but when I tried to execute it gave me the "Exception in
thread "main" java.lang.NoClassDefFoundError: QuadraticB
Press any key to continue...." error.
Anyhow, the problem:
Problem B: Write a Java class (call it Quadratic) that contains private instance variables for each of the 3 coefficients (a, b, c) and private instance variables for the two roots of a quadratic equation. Include the following instance methods: (each MUST refer directly to one or more instance variables)
�Default constructor with no parameters for the coefficients, which will assign 0 to coefficients instance variables.
�Constructor with 3 double parameters for the coefficients, which will assign the parameters to the coefficients instance variables. Call the method to calculate the roots here.
�Constructor with 2 double parameters (for a & b only, assigning c to 0), calling the previous constructor with the parameters for a & b, and 0 for c.
�Private instance (not static) method which will calculate and assign to both root instance variables a root. This will be called from each constructor and mutator/modifier method. The roots calculations are on the next page.
�accessor methods, one for each instance variable and roots.
�mutator method to change all three coefficients (a, b or c) ONLY in one method (call roots method here, too)
�a Boolean method called isQuadratic that returns (in a return statement) true if "a" isn't 0 (is a quadratic) or false if "a" is 0
�a Boolean method called isImaginary that returns (in a return statement) true if (b2-4ac) is negative or false otherwise
�Display method that displays the name of the class, each variable name (all 3 coefficients and 2 roots) and their values
Formulas for the roots (you convert to Java expressions):
(-b + squareroot(b2-4ac)) / 2a
(-b - squareroot(b2-4ac)) / 2a
Write a Java application program in which main is in a separate file and class from the Quadratic class. Have the program declare a Quadratic object variable and assign to an instance of a Quadratic object with the 2., 5. (nothing for c) passed from main. Call the display method for that object.
**Prompt & input from the user 3 coefficients and change the object var. using it's mutator method. In main, call the isQuadratic method on the Quadratic object and print "Not a quadratic" if it returns false, but if it returns true, call the isImaginary method on the Quadratic object and print "Imaginary Roots" if it's true, otherwise print ONLY the two roots (in main, call the accessors for the roots).
Prompt the user and input if the user wants to continue. Read the answer into a
String, and repeat from ** if the first char. of the answer is 'y' or 'Y'.
8. 3. 4.//Output from toString or display (for a, b, c)
Yes
0. 1. 2.
Y
-2.5 4. 3.
No
Quitting....
(cut & pasted from instruction, not lying....)
So, my code as I understand him to be asking for in the problem, minus the quadcalc (I know is a mess, but a work in progress....):
Sigh, when you are through laughing and find composure, can you find it in your heart to help?
thanks again
Sammi