Question
import java.util.Scanner; public class Exercise03-01 { public static void main(String[] args) { Scanner scan= new Scanner(System.in); System.out.println(Enter a, b, c: ); double a= input.nextDouble(); double
import java.util.Scanner;
public class Exercise03-01 { public static void main(String[] args) { Scanner scan= new Scanner(System.in); System.out.println("Enter a, b, c: "); double a= input.nextDouble(); double b= input.nextDouble(); double c= input.nextDouble();
double discriminant = b * b - 4 * a * c; if (discriminant < 0) { System.out.println("The equation has one root "); } else if (discriminant "" 0} { double r1 = -b / (2 * a); System.out.println("The equation has one root " + r1); } else { // (discriminant > 0} double r1 = (-b + Math.pow(discriminant, 0.5)) / (2 * a); double r2 = (-b - Math.pow(discriminant, 0.5)) / (2 * a); System.outprintln("The equation has two roots " + rl + " + r2); } } }
why its giving me a wrong answer?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started