-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalculator
38 lines (34 loc) · 950 Bytes
/
Calculator
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
38
public class Calculator{
public Calculator(){
}
public int add( int a, int b){
return a +b ;
}
public int subtract(int a, int b) {
// Logic to return the difference of a and b
return a - b;
}
public int multiply(int a, int b) {
// Logic to return the product of a and b
return a * b;
}
public int divide(int a, int b){
// Logic to return the product of a and b
return a / b;
}
public int modulo(int a, int b) {
// Logic to return the remainder of a divided by b
return a % b;
}
public static void main(String[] args) {
// Code to execute
Calculator myCalculator = new Calculator();
System.out.println(myCalculator.add(5, 7));
System.out.println(myCalculator.subtract(45, 11));
/*
This is a basic calculator program that performs simple arithmetic operations.
It can add, subtract, multiply, divide, and find the modulo of two integers.
Created as part of a Codecademy project.
*/
}
}