왜 틀린건지 모르겠습니다...

LeeSangwon Reply 7 years 7 weeks ago
import java.util.Scanner; public class Main{ static double func1(double a,double b,double c){ return Math.pow(b,2) - 4*a*c; } static double func2(double a, double b, double c){ return (-1*b + Math.pow(func1(a, b, c),0.5))/(2*a); } static double func3(double a, double b, double c){ return (-1*b - Math.pow(func1(a, b, c),0.5))/(2*a); } public static void main(String[] args){ Scanner input = new Scanner(System.in); double a = input.nextDouble(); double b = input.nextDouble(); double c = input.nextDouble(); if(func1(a, b, c) >= 0){ double bigger = (func3(a,b,c) > func2(a,b,c)) ? func3(a,b,c) : func2(a,b,c); System.out.printf("%.1f\n", bigger); } else if (func1(a,b,c)< 0){ System.out.println("complex"); } } } 어디가 잘못된지 잘 모르겠습니다...
withcs1 Reply 7 years 7 weeks ago
소수점 두째자리부터는 버리셔야해요 반올림되고있습니다 질문시 코드는 복붙하지마세요~