Why missing return return statement? It's there in my code


#1


Calculator.java:36: error: missing return statement
}//end of block 7
^
1 error


  

  
public class Calculator {//start of block 1 for class Calculator
  
  public Calculator() {//start of block 2
    
  }//end of block 2

  public int add(int a, int b) {//start of block 3
  		return a + b;
}//end of block 3
  

  public int subtract(int a, int b) {//start of block 4
			return a - b;
}//end of block 4

  public int multiply(int a, int b) {//start of block 5
  		return a * b;
  }//end of block 5
  
  public int divide(int a, int b) {//start of block 6 for divide
  	if (b==0) {//start of if block for divide
   	 System.out.println (" Error! Dividing by zero is not allowed");
    	return 0;
    }//end of if block for divide
  //end of block 6 for divide
    else {//start of else statement block for divide
      return a/b; }//end of else statement block for divide
  }

public int modulo(int a, int b) {//start of block 7
if (b==0) {//start of if statement block for modulo
System.out.println ("Error! Dividing by zero is not allowed.");
return 0; }//end of if statement block for modulo**strong text**
}//end of block 7**strong text**
`

public static void main(String [ ] args) {//start of main block

}//end of main block

}//end of block 1 for class Calculator

Heading

`


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.