Write a program to solve the equation y=(a*x*x)+(b*x)+c | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Write a program to solve the equation y=(a*x*x)+(b*x)+c

5th Mar 2017, 6:59 PM
wanou
wanou - avatar
2 Answers
+ 3
you are missing "home" from your tags. Take your math book and look at the end of the equation chapter. They usually include some code in Pascal or some other antiquity, to show the book is cool while it is not...
5th Mar 2017, 7:12 PM
seamiki
seamiki - avatar
0
*solution in Java* public static int[] class giveAns(int a, int b, int c, int y){ c -= y; a /= a; b /=a; c /=a; int d = (b*b) - (4*a*c); int x1 = ((-1*b) + Math.sqrt(d))/(2*a); int x2 = ((-1*b) - Math.sqrt(d))/(2*a); int[] ans = {x1, x2}; return ans; }
5th Mar 2017, 9:04 PM
Pankaj Vaghela
Pankaj Vaghela - avatar