Codecademy whats up, i’m back again with a small problem.
I’ve been going over & over (restarting the project) because
OOP lesson has been a bit tough for me. I have to say now
I am understanding it ALOT better thanks to the restart task
button. Anyways i’ve written this Basic Calculator code &
i’m not understanding where i’m going wrong or why. Any help
would be appreciated, thanks in advance!
public 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.");
}
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));
}
}
Edit: Here is the error message I forgot to mention.
Calculator.java:2: error: missing method body, or declare abstract
public Calculator(); {
^
1 error