-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArithmetic.java
More file actions
24 lines (24 loc) · 822 Bytes
/
Copy pathArithmetic.java
File metadata and controls
24 lines (24 loc) · 822 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
class Arithmetic {
public static void main(String[] rds) {
if (rds.length != 3) {
System.out.print("Please enter right input.");
} else {
int x = Integer.parseInt(rds[0]);
int y = Integer.parseInt(rds[1]);
int a;
if (rds[2].equals("+")) {
a = x + y;
System.out.print(x + "+" + y + "=" + a);
} else if (rds[2].equals("-")) {
a = x - y;
System.out.print(x + "-" + y + "=" + a);
} else if (rds[2].equals("*")) {
a = x * y;
System.out.print(x + "*" + y + "=" + a);
} else {
a = x / y;
System.out.print(x + "/" + y + "=" + a);
}
}
}
}