Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

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

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students explore these related Databases questions

Question

What is cost plus pricing ?

Answered: 3 weeks ago