I can't seem to see the mistake here


#1


class Calculator {
  
  int a;
  int b;

	public Calculator() {
    
  }
  
  public add() {
		return (a+b);
    
	}
	
  public substract() {
    return (a-b);

	}
  
  public multiply() {

    return (a*b);
    
	}
  
    public divide() {
      
      if (b <=0){
        
       System.out.println("Error! Dividing by zero is not allowed."); 
        return 0;
        
      } else { 
      	return (a/b);
      }
	}
  
  public modulo(){
    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.substract(45,11));
	}

}


#2

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