So the exercise tells me to get the values a, b and c from the user and then use the quadratic formula to get both roots.
if both are above 0, display both roots
if both are 0, display 1 root
if both are negative, no real root
So all is good until this:
if (root1 && root2 > 0) {
System.out.println("The equation has two roots: " + root1 + " and " + root2);
else if(root1 && root2 == 0) {
System.out.println("The equation has one root: " + root1);
}
}else{
System.out.println("The equation has no real roots");
}
if i only placed the braces on if and else (but not else if) the compiler doesn't recognise else and wants it disposed, if i place the braces on all, it says i cant convert double into int even tho i didnt specify anything of the sort.
Could you guys help me out ? much thanks!