Created
August 25, 2017 22:11
-
-
Save khayyamsaleem/dd7ba68a8a9dedb3a8e1aec3e821ab8b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Calculator { | |
public void 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"); | |
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.subtract(45,11)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment