package javaapplication14;
import java.util.Scanner;
public class Javaapplication14 {
public static void main(String[] args) {double n1,n2,n3;
System.out.println("Enter number 1");
Scanner n11 =new Scanner(System.in);
n1=n11.nextDouble();
System.out.println("Enter number 2");
Scanner n12 =new Scanner(System.in);
n2=n12.nextDouble();
System.out.println("Enter number 3");
Scanner n13 =new Scanner(System.in);
n3=n13.nextDouble();
double result = n2*n2 - 4*(n1*n3);
if(result>0)
{
double r1=(-n2+Math.pow (result,0.5))/2*n1;
double r2=(-n2-Math.pow (result,0.5))/2*n1;
System.out.println("The root of r1= " +r1+"and r2 = "+r2);
}
else
{
System.out.println("The equation has not Any solution");
}
}
}
Comments
Post a Comment