Skip to content
Snippets Groups Projects
Commit 3bfb9461 authored by Mahboobe Shakeri's avatar Mahboobe Shakeri
Browse files

calculator class added

parent 33b327e2
No related branches found
No related tags found
No related merge requests found
public class Calculator {
// Method to add two numbers
public int add(int a, int b) {
return a + b;
}
// Method to subtract two numbers
public int subtract(int a, int b) {
return a - b;
}
// Method to multiply two numbers
public int multiply(int a, int b) {
return a * b;
}
// Method to divide two numbers
public int divide(int a, int b) {
if (b == 0) {
throw new IllegalArgumentException("Cannot divide by zero");
}
return a / b;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment