Code for polynomial equation? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
25th Feb 2020, 10:11 AM
Dhaxtremist
Dhaxtremist - avatar
4 Answers
+ 1
One of your problems is you need an endquote on line 39 to enclose the string in the print statement
25th Feb 2020, 10:49 AM
Kylie
Kylie - avatar
0
There are some mistakes in variable names and in the method declaration - you put ";" and in string which you print. Look at the code 🐱 https://code.sololearn.com/cNoiSAWHS83i/?ref=app
25th Feb 2020, 10:52 AM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
0
import java.util.Scanner; class polynomialEquation { public static void main (String[] args) { //TODO Auto-generated method stub double a, b, c; Scanner in = new Scanner (System.in); System.out.println("Enter thw values of a b and c"); a=in.nextDouble(); b=in.nextDouble(); c=in.nextDouble(); findingRoots fr = new findingRoots(); fr.calValue (a, b, c); } } class findingRoots { void calValue (double a, double b, double c) { double dis ; double roots; if(a==0) { System.out.println("it is not in quadratic form"); return; } dis = Math.pow (b, 2.0) - 4*a*c; roots =Math.sqrt (Math.abs(dis)); if(dis>0) { System.out.println("The roots of given quadratic equation are real and different"); System.out.print("Values of roots: *"); System.out.println ((double) (-b + roots) / (2*a) + (double) (-b - roots)/(2*a)); } else {
25th Feb 2020, 11:28 AM
ASNM
ASNM - avatar
0
Still not running😭😭
25th Feb 2020, 11:51 AM
Dhaxtremist
Dhaxtremist - avatar