-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
25 lines (21 loc) · 781 Bytes
/
Copy pathMain.java
File metadata and controls
25 lines (21 loc) · 781 Bytes
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
/**
* Demo entry point showing basic usage of the Calculator class.
*/
public class Main {
public static void main(String[] args) {
Calculator calculator = new Calculator();
double a = 12;
double b = 4;
System.out.println("Calculator Demo");
System.out.println("a = " + a + ", b = " + b);
System.out.println("a + b = " + calculator.add(a, b));
System.out.println("a - b = " + calculator.subtract(a, b));
System.out.println("a * b = " + calculator.multiply(a, b));
System.out.println("a / b = " + calculator.divide(a, b));
try {
calculator.divide(a, 0);
} catch (ArithmeticException e) {
System.out.println("Error caught: " + e.getMessage());
}
}
}