![]() ![]() ("Enter the value of b.") ī=sc.nextDouble() //Quadratic Variables Initialization ("Enter the value of a.") Ī=sc.nextDouble() //Quadratic Variables Initialization Java Program to find the roots of the quadratic equationĭouble a,b,c //Quadratic Variables declaration And then we directly find the roots of the quadratic equation in the main method itself. Firstly, the coefficients of the quadratic equations are declared and initialized. In this example, we will directly find the roots of the quadratic equations. ![]() If discriminant>0, then the roots are complex and different.Calculate the roots as (-b + Discriminant) /( 2*a).If discriminant=0, then the roots are real and equal.Calculate the roots as ( -b+ discriminant ) /(2 *a) and ( -b - discriminant ) /(2 *a).If discriminant.>0, then the roots are real and unequal.Calculate the discriminant as Discriminant= sqrt((b*b)-(4*a*c)).Check whether roots are possible or not using condition a=0.Calculate the roots of the quadratic equation in the main method itself. ![]() In this program, roots of the quadratic equations are found out in the main method itself. Output: 1 1 Program 1: Find Quadratic Equation Here, we are given a quadratic equation and our task is to find the roots of that equation.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |