#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

Ashishkumar Vishwakarma

I am Ashish- a Developer and Artist live in Mumbai.

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

  • April 22, 2020 at 2:24 AM
    Permalink

    Thanks for the info 🙂

    Reply
  • April 19, 2020 at 1:20 AM
    Permalink

    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

    Reply
  • April 16, 2020 at 10:40 PM
    Permalink

    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.

    Reply

Leave a Reply