#3 :WAP to implement Quadratic equation .

SOURCE CODE.

import java.util.*;
class quadratic3
{
	public static void main(String args[])
	{
		int e,a,b,c;
		double l,x,y;
		Scanner s= new Scanner(System.in);
		System.out.println("Enter value a,b,c:");
		a=s.nextInt();
		b=s.nextInt();
		c=s.nextInt();
		
		e=b*b-4*a*c;
		if(e<0)
		{
			System.out.println("NOT REAL");
		}
			else if(e == 0) 
		{
                 x = -b / (2.0 * a);
                System.out.println("The root is " + x);
		}
		else 
		{
			l=Math.sqrt(e);
			x= (-b+l)/(2*a);
			y= (-b-l)/(2*a);
			System.out.println("equation= "+x+" & "+y);
		}
	}// END OF MAIN
}//END OF CLASS


		

OUTPUT.

C:\A>javac quadratic3.java
C:\A>java quadratic3
Enter value a,b,c:
1
4
4
The root is -2.0

OR

C:\A>javac quadratic3.java
C:\A>java quadratic3
Enter value a,b,c:
1
5
2
equation= -0.4384471871911697 & -4.561552812808831

3 thoughts on “#3 :WAP to implement Quadratic equation .

  1. I think this is among the most vital info for me. And i’m glad reading your article. But should remark on few general things, The site style is great, the articles is really nice : D. Good job, cheers

  2. Hey very nice web site!! Man .. Beautiful .. Superb .. I will bookmark your blog and take the feeds additionally…I am happy to search out so many helpful information here within the publish, we want work out extra strategies on this regard, thanks for sharing.

Leave a Reply