Write a program that prompts the user to input the value of a (the coefficient o
ID: 3527606 • Letter: W
Question
Write a program that prompts the user to input the value of a (the coefficient of x 2 ), b (the coefficient of x), and c (the constant term), and outputs the type of roots of the equation. Furthermore, if b 2 4ac 0, the program should output the roots of the quadratic equation.
I need the program to prompt up in a cmdwindow andask for
"The coefficent of x square"
"The coefficent of X"
"constant term"
at the end of the prompt it needs to say "The equation has complex roots"
It needs to be in java!
Explanation / Answer
import java.util.*;
class test
{
public static void main(String[] args)
{
int a,b,c;
Scanner in = new Scanner(System.in);
System.out.println(" enter The coefficent of x square ");
a = in.nextInt();
System.out.println(" enter The coefficent of X ");
b = in.nextInt();
System.out.println(" enter constant term ");
c = in.nextInt();
if((b*b- 4*a*c) < 0)
System.out.println("The equation has complex roots");
}
}