Hello

I´ve finished the “Basic Calculator” project, but i have a question about the .divide method

First, here´s my code:

class Calculator{

public Calculator(){

}

public int add(int a, int b){

return a + b;

}

public int subtract(int a, int b){

return a - b;

}

public int multiply(int a, int b){

return a*b;

}

public int divide(int a, int b){

```
if( b == 0) {
System.out.println("Error! Dividing by zero is not allowed.");
return 0;
} else{
return a / b;
}
```

}

public int modulo(int a, int b){

```
if( b == 0) {
System.out.println("Error! Dividing by zero is not allowed.");
return 0;
} else {
return a % b;
}
```

}

public static void main(String[]args) {

Calculator myCalculator = new Calculator();

System.out.println(myCalculator.add(5,7));

System.out.println(myCalculator.subtract(45,11));

System.out.println(myCalculator.divide(5,0));

}

}

I don´t understand why we have to return 0 (zero), inside the “if”, after we print out the Error message.

any thoughts?

thanks