-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab10.java
More file actions
36 lines (30 loc) · 1.1 KB
/
lab10.java
File metadata and controls
36 lines (30 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.util.*;
public class lab10
{ //Program by Pranay Bokde
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter the first term of Equation:");
double a=sc.nextDouble();
System.out.print("Enter the second term of Equation:");
double b=sc.nextDouble();
System.out.print("Enter the third term of Equation:");
double c=sc.nextDouble();
double D=(b*b)-(4*a*c); //formula for
if (D>0)
{
double first_root=(-b+Math.sqrt(D))/(2*a);
double second_root=(-b-Math.sqrt(D))/(2*a);
System.out.println( "First Root of the Equation is"+ first_root);
System.out.println( "Second Root of the Equation is"+ second_root);
}
else if (D==0){
double equal_root=(-b+Math.sqrt(D))/(2*a);
System.out.println( "Equal Roots is:"+ equal_root);
}
else
{
System.out.println( "Roots are imaginary.");
}
}
}