forked from zoe-ang17/Ang_ArithmeticCalculator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalculator.java
32 lines (24 loc) · 903 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
import java.util.Scanner;
public class Calculator {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print(
"Enter the first and the Second number: ");
int num1 = sc.nextInt();
int num2 = sc.nextInt();
double result;
result = num1 + num2;
System.out.println("Addition: " + result);
result = num1 - num2;
System.out.println("Subtraction: " + result);
result = num1 * num2;
System.out.println("Multiplication: " + result);
if(num1 != 0 && num2 != 0) {
result = (double) num1 / num2;
System.out.println("Division: " + result);
}
else{
System.out.print("It is not possible to divide by 0!!");
}
}
}