import java.lang.*;
import java.io.*;
class Quadratic
{
public static void main(String args[])
{
double b=12.1,a=2.35,c=12.50,dis,root1,root2;
dis=(b*b)-(4*a*c);
root1=(-b+Math.sqrt(dis)/2*a);
root2=(-b-Math.sqrt(dis)/2*a);
if(root1<=0 && root2<=0)
{
System.out.println("Roots are imaginary");
}
else
{
System.out.println("The result is:"+root1);
System.out.println("The result is:"+root2);
}
}
}
import java.io.*;
class Quadratic
{
public static void main(String args[])
{
double b=12.1,a=2.35,c=12.50,dis,root1,root2;
dis=(b*b)-(4*a*c);
root1=(-b+Math.sqrt(dis)/2*a);
root2=(-b-Math.sqrt(dis)/2*a);
if(root1<=0 && root2<=0)
{
System.out.println("Roots are imaginary");
}
else
{
System.out.println("The result is:"+root1);
System.out.println("The result is:"+root2);
}
}
}
0 comments:
Post a Comment