}
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");
}
else {
return a / b;
}
return 0;
}
public int modulo(int a, int b) {
if (b == 0) {
System.out.println(“Error! Dividing by zero is not allowed.”);
}
else {
return a % b;
}
return 0;
}
public static void main (String args) {
Calculator myCalculator = new Calculator();
Hmm
So i followed the instructions and it says it should add the numbers and subtract the number in the main method. The result should show in the right side window but nothing happens. I have no idea what i did wrong.
That is how you would print but that isn’t how you call a method.
Nothing will print unless you tell it to.
So obtain the value and then print the value