当我尝试为二次公式创建方法时,它不会给我任何输出,而且我一直在丢失精度错误。我目前需要任何帮助,因为我似乎无法弄清楚。这是我的代码:
import java.util.Scanner;
public class HelperMethod {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.println("Pick an option:");
System.out.println("Option 1: Quadratic Formula");
System.out.println("Option 2: Newtons Method");
System.out.println("Option 3: ISBN checker");
int option = keyboard.nextInt();
if(option == 1){
System.out.print("Please enter an 'a' value:");
double a = keyboard.nextDouble();
System.out.print("Please enter a 'b' value:");
double b = keyboard.nextDouble();
System.out.println("Please enter 'c' value:");
double c = keyboard.nextDouble();
}
}
public int quadraticFormula(double a, double b, double c, boolean returnSecond){
return (-b + Math.sqrt(b * b - 4.0 * a * c))/(2.0 * a);
}
}
输出:没有回答我的问题
Pick an option:
Option 1: Quadratic Formula
Option 2: Newtons Method
Option 3: ISBN checker
1
Please enter an 'a' value:2
Please enter a 'b' value:3
Please enter 'c' value:
4
Process completed.