-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCalculator.java
37 lines (29 loc) · 980 Bytes
/
Calculator.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
public class Calculator {
// This class contains methods to perform basic arithmetic operations
Calculator() {
System.out.println("Calculator object created");
}
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) {
return a / b;
}
public int modulo(int a, int b) {
return a % b;
}
public static void main(String[] args) {
Calculator calculator = new Calculator();
System.out.println("Addition: " + calculator.add(10, 20));
System.out.println("Subtraction: " + calculator.subtract(10, 20));
System.out.println("Multiplication: " + calculator.multiply(10, 20));
System.out.println("Division: " + calculator.divide(10, 20));
System.out.println("Modulo: " + calculator.modulo(10, 7));
}
}