Class Exception
My error:
Exception in thread "main" java.lang.NoClassDefFoundError.
I already looked through the forums and tried the class path fix and also made sure my main method was in there. It compiles fine and chances are would work on the systems on campus but lately none of my programs have been running at home. All get that error message, even ones that used to work when I originally installed JSE. Here's the code I'm working on at the moment. The format will probably get messed up but you'll get the picture. Someone help please?
import java.io.*; // used for input
public class Quadratic
{
private float a; // instantiates the coefficient of x^2
private float b; // instantiates the coefficient of x
private float c; // instantiates the constant
private float q; // variable for the new formula
private float disc; // declares the discriminate
private float root1; // declares the first root
private float root2; // declares the second root
// constructs a quadratic equation
public void quadratic(float givenA, float givenB, float givenC)
{
a = givenA;
b = givenB;
c = givenC;
} // ends constructor
// Main Method
public void main(String[] args) throws IOException
{
BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
// allows for input
// user input a variable
System.out.println("Enter the coefficient of x^2:");
String value1 = console.readLine();
float a = Float.parseFloat(value1);
// user input b variable
System.out.println("Enter the coefficient of x:");
String value2 = console.readLine();
float b = Float.parseFloat(value2);
// user input c variable
System.out.println("Enter the constant:");
String value3 = console.readLine();
float c = Float.parseFloat(value3);
if( a == 0 && b != 0 ) // checks if it's a linear equation
{
System.out.println("This is a linear equation.");
}
else if( a == 0 && b == 0 && c != 0 ) // checks if it's a true constant equation
{
System.out.println("The statement is false.");
}
else if( a == 0 && b == 0 & c == 0 ) // gives a constant root
{
System.out.println("This is a constant equation and x = 0.");
}
else
{
traditional();
newFormula();
}
} // end main
public void traditional() // uses the traditional quadratic calculation method
{
disc = b * b - 4 * a * c ; // declares discriminate
root1 = ( - b + (float) Math.sqrt(disc) ) / ( 2 * a ); // gives first root
root2 = ( - b - (float) Math.sqrt(disc) ) / ( 2 * a ); // gives second root
System.out.println( "Traditional Method: This is a quadratic equation./n");
System.out.println( "Where a = " + a + ", b = " + b + ", and c = " + c + "," );
System.out.println( "the first root is " + root1 + " and" );
System.out.println( "the second root is " + root2 + ".");
} // end Traditional method
public void newFormula() // uses the new quadratic calculation method
{
if ( b >= 0 )
{
disc = b * b - 4 * a * c ; // declares discriminate
q = - ( b + (float) Math.sqrt( disc ) ) / 2 ; // gets new equation
root1 = q / a; // gives first root
root2 = c / q; // gives second root
System.out.println( "New Method: This is a quadratic equation./n");
System.out.println( "Where a = " + a + ", b = " + b + ", and c = " + c + "," );
System.out.println( "the first root is " + root1 + " and" );
System.out.println( "the second root is " + root2 + ".");
}
else if ( b < 0 )
{
disc = b * b - 4 * a * c ; // declares discriminate
q = - ( b - (float) Math.sqrt( disc ) ) / 2; // gets new equation
root1 = q / a; // gives first root
root2 = c / q; // gives second root
System.out.println( "New Method: This is a quadratic equation./n");
System.out.println( "Where a = " + a + ", b = " + b + ", and c = " + c + "," );
System.out.println( "the first root is " + root1 + " and" );
System.out.println( "the second root is " + root2 + ".");
}
} // end new Formula
} // end class

