vendredi 24 avril 2015

How do I make this output a boolean?

So here's my code, I want the output to be like this:

Given two numbers, is the second input a multiple of the first?

For Example:

Input:

3

6

Output:

true

public boolean multiple(int m, int n){

    int i = 0;
    int j = 0;

    boolean check = true;
    if(n%m == 0){
        i++;
        return check;
    }
    else{
        j++;
        return false;
    }
}

When I try it I get an error, I think it's because the return statement is within the if and else statements.

Aucun commentaire:

Enregistrer un commentaire