This is my main class:
import java.util.Scanner;
public class calc {
public static void main(String[] args){
Scanner variablea = new Scanner(System.in);
Scanner variableb = new Scanner(System.in);
Scanner variablec = new Scanner(System.in);
int a1, b1, c1;
System.out.println("enter your 'A' variable");
a1 = variablea.nextInt();
System.out.println("enter your 'B' variable");
b1 = variableb.nextInt();
System.out.println("enter your 'C' variable");
c1 = variablec.nextInt();
algorithm algorithmObject = new algorithm();
algorithmObject.algorithm(a1, b1, c1);
}
}
and this is the second one
public class algorithm{
public void algorithm(int a, int b, int c){
double x1;
double square = Math.sqrt(b*b - 4*a*c);
double numerator = b*-1 + square;
double finalanswer = numerator/2*a;
System.out.println(finalanswer);
}
}
Eclipse doesn't give me any errors, but after it asks for my 3 variables and I enter them, it just gives NaN. Any idea what I have done wrong?