Need Help with the Calculator!

I dont get why my code isnt working?? i get an error class?

public class Calculator {
  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 x, int y) {
      return a * b;
    }
    public int divide(int a, int b) {
      return a / b;
    }
    public int modulo(int a, int b) {
      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));
  }
}

the main method doesn’t seem to be part of your class.

i still get the errors when i change that?

Can you share an updated version of your code and the exercise url so i can run your code

https://www.codecademy.com/courses/learn-java/projects/basic-calculator

public class Calculator {
  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 x, int y) {
      return a * b;
    }
    public int divide(int a, int b) {
      return a / b;
    }
    public int modulo(int a, int b) {
      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));
  }
}
public class Calculator {
  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 x, int y) {
      return a * b;
    }
    public int divide(int a, int b) {
      return a / b;
    }
    public int modulo(int a, int b) {
      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));
  }
}

i think the error message is quite useful? Looking at the method involved:

public int multiply(int x, int y) {
      return a * b;
    }

then seeing what you named your parameters and what variable you use in the body of the method, i can see where the error comes from

do you mean that i used the wrong method?

instead of int use double?

the type declaration is fine, is was about the name of your parameter variable (x and y) and then which variable (a, b) you used within the body of the method

is that better?

public class Calculator {
  Calculator() {
   
    public int add(int a, int b) {
    return add = a + b;
    }
    public int subtract(int a, int b){
    return subtract = a - b;
    }
    public int multiply(int x, int y){
      return multiply = x * y;
    }
    public int divide(int a, int b){
      return divide = a / b;
    }
    public int modulo(int a, int b){
      return modulo = a % b;
    }
    public static main void(String[] args){
    Calculator myCalculator = new Calculator();
      System.out.println(myCalculator.add(5, 7));
      System.out.println(myCalculator.subtract(45, 11));
  }
}

i still seem to get an error?
this time its an identifier error and illegal start of expression

now you forgot to close your constructor:

Calculator() { // missing }

When you have an error, take your time. What could this error mean? Maybe i could google for additional clarification?

Hey sorry, it looks like you just need to declare the two instance variables at the top.

furthermore, here:

return divide = a / b;

you can’t assign and return at the same line. You really must take more time to understand what you are doing and not apply a trail and error approach