15,357,967 members
1.00/5 (1 vote)
See more:
```I am actually getting " <identifier> expected " error for parameters passed in methods.
```

What I have tried:

```import java.util.Scanner;
import java.lang.Math;

{
int a,b,c;
float d,x1,x2;

void discriminant( a, b, c)
{

d = b*b - 4*a*c;

if(d<0)
{
System.out.println("Roots are imaginary.");
}
else if (d>0)
{
System.out.println("Roots are real and unequal. ");
roots(a,b,c);
}
else
{
System.out.println("Roots are real and equal. ");
roots(a,b,c);
}

}

void roots(a, b, c)
{

x1 = (-b - Math.sqrt(d))*0.5;
x2 = (-b + Math.sqrt(d))*0.5;

System.out.println("Roots of the equation are " + x1 + "and " + x2 + " .");
}
}

public class Program3
{

public static void main(String[] args)
{
int a1, a2, a3;

Scanner sc = new Scanner(System.in);

System.out.println("Enter the value of a :");
a1 = sc.nextInt();

System.out.println("Enter the value of b :");
a2 = sc.nextInt();

System.out.println("Enter the value of c :");
a3 = sc.nextInt();

obj.discriminant(a1,a2,a3);
sc.close();

}
}```
Posted
Updated 17-Jul-21 21:27pm

## Solution 1

You need to declare the parameter types in your function definitions:
Java
```void discriminant( a, b, c) // the compiler cannot guess the types of a, b and c

// correct way
void discriminant(int a, int b, int c) // tell the compiler the types of the inputs```

And the same for the `roots` function. Although you probably need to make all variables float type for consistency.
Hemil Shah 2021 18-Jul-21 3:41am

Thanks for the quick response !

I actually did that at first but it seemed to be didn't work again, maybe because of some other errors as well. Nonetheless it working now! Cheers