-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathArithmeticOperator1.java
More file actions
24 lines (22 loc) · 858 Bytes
/
Copy pathArithmeticOperator1.java
File metadata and controls
24 lines (22 loc) · 858 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
package Day_01;// Write a program to get an Arithmetic operator as input and show its use with example.
// using ladder if else...
import java.util.Scanner;
public class ArithmeticOperator1 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
char operator=sc.next().charAt(0);
if(operator == '+'){
System.out.println("5 + 6 = "+(5+6));
} else if (operator == '-') {
System.out.println("5 - 6 = "+(5-6));
} else if (operator == '*'){
System.out.println("5 * 6 = "+(5*6));
} else if (operator == '/') {
System.out.println("5 / 2 = "+(5/2));
} else if (operator == '%') {
System.out.println("5 % 2 = "+(5%2));
}else {
System.out.println("INVALID ARITHMETIC OPERATOR!!!");
}
}
}