Question
Can someone help me with this Quadratic Solver Java code. Here is my code: import java.util.Scanner; public class QuadraticSolver{ public static void main (String []
Can someone help me with this Quadratic Solver Java code.
Here is my code:
import java.util.Scanner;
public class QuadraticSolver{ public static void main (String [] args){ double a = 4.0; double b = -5.0; double c = 1.0;
double dis = b * b - 4.0 * a * c;
if (dis > 0.0) { double r1 = (-b + Math.pow(dis, 0.5)) / (2.0 * a); double r2 = (-b - Math.pow(dis, 0.5)) / (2.0 * a); System.out.println("The equation has two roots: " + r1 + " and " + r2); } else if (dis == 0.0) { double r1 = -b / (2.0 * a); System.out.println("The equation has one root: " + r1); } else { System.out.println("The equation has no root."); } } }
Output differs. See highlights below. Input Your output The equation has two real solutions, x1=1.0,x2=0.25 Expected output The equation has two roots: 0.38 and 2.62Step 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