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.

Can someone help me with this Quadratic Solver Java code. Here is

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.62

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!