这是我的主要课程:
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);
}
}
这是第二个
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 没有给我任何错误,但是在它询问我的 3 个变量并输入它们之后,它只给出了 NaN。知道我做错了什么吗?