-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArithmatic_operation.java
More file actions
51 lines (28 loc) · 1.02 KB
/
Copy pathArithmatic_operation.java
File metadata and controls
51 lines (28 loc) · 1.02 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.util.Scanner;
import java.util.*;
public class Arithmatic_operation {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int num1 = in.nextInt();
int num2 = in.nextInt();
System.out.println("Enter operator");
char operator =in.next().charAt(0);
if (operator=='+'){
System.out.println(num1+num2);
}
else if(operator=='-'){
System.out.println(num1-num2);
}
else if (operator=='*'){
System.out.println(num1*num2);
} else if (operator== '/'){
if(num2 !=0){
System.out.println(num1/num2);
}else{
System.out.println("Zero division error");
}
}else{
System.out.println("Please enter correct input: ");
}
}
}