Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created September 27, 2019 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/bd9f9656e6bca2fcc739e4ce544716b3 to your computer and use it in GitHub Desktop.
Save codecademydev/bd9f9656e6bca2fcc739e4ce544716b3 to your computer and use it in GitHub Desktop.
Codecademy export
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(){
return a/b;
{
if (b==0)
{
System.out.println("Error! Diving 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! Diving by zero is not allowed!");
}
else {
return a % b;
}
public static void main(String[] args){
Calculator myCalculator = new Calculator();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment