I keep getting the same error which makes no sense to me.
Exercise03_01.java:5: error: class Exercise_03_01 is public, should be declared in a file named Exercise_03_01.java
public class Exercise_03_01 {
Heres my code:
import java.util.Scanner;
public class Exercise_03_01 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter a, b and c: ");
// Prompt for user to enter the inputs
double a = input.nextDouble();
double b = input.nextDouble();
double c = input.nextDouble();
// Compute the discriminant of the equation.
double discriminant = Math.pow(b, 2) - 4 * a * c;
System.out.print("The equation has ");
if (discriminant > 0)
{
double root1 = (-b + Math.pow(discriminant, 2)) / (2 * a);
double root2 = (-b - Math.pow(discriminant, 2)) / (2 * a);
System.out.println("two roots " + root1 + " and " + root2);
}
else if (discriminant == 0)
{
double root1 = (-b + Math.pow(discriminant, 2)) / (2 * a);
System.out.println("one root " + root1);
}
else
System.out.println("no real roots");
}
}