First of all you don't need to declare g
and c
again in the function multiple
(It is an error). Second, you didn't call the function at all, you just implemented it. And like other people answered, you need to have ==
instead of =
.
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
int a,b;
System.out.println("enter the first number");
a=input.nextInt();
System.out.println("enter the first number");
b=input.nextInt();
boolean result = multiple(a,b);
System.out.println(result);
}
public static boolean multiple (int g,int c){
if (g%c==0){
return true;
}
else
{
return false;
}
}
Note that you can have a shorter version of multiple
which have only one line: return g%c==0;