forked from Aniket965/Hello-world
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyOperators.java
More file actions
executable file
·61 lines (43 loc) · 2.23 KB
/
MyOperators.java
File metadata and controls
executable file
·61 lines (43 loc) · 2.23 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
52
53
54
55
56
57
58
59
60
61
import java.util.Scanner;
public class MyOperators{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int sum,sub,mul,div,mod,max=0;
System.out.println("Enter two values");
int a = scan.nextInt();
int b = scan.nextInt();
System.out.println("\nThere Arithmetic Operations are\n===========================");
sum = a+b;
sub = a-b;
mul = a*b;
div = a/b;
mod = a%b;
max = a>b?a:b;
System.out.println("Addition is : "+sum);
System.out.println("Subtraction is : "+sub);
System.out.println("Multiplication is : "+mul);
System.out.println("Division is : "+div);
System.out.println("Modulas is : "+mod);
System.out.println("\nRelational Operations are\n==================================");
System.out.println("A is greater then b : "+(a>b));
System.out.println("A is smaller then b : "+(a<b));
System.out.println("A is greater or equal to b : "+(a>=b));
System.out.println("A is smaller or equal to b : "+(a<=b));
System.out.println("A is equal to b : "+(a==b));
System.out.println("A is not equal to b : "+(a!=b));
System.out.println("\nLogical Operators are\n======================================");
System.out.println("A is larger then b and b is smaller then A : "+(a>b && b<a));
System.out.println("A is larger then b or b is smaller then A : "+(a>b || b<a));
System.out.println("A is not smaller then b : "+(!(a<b)));
System.out.println("\nIncrement and decrement operators are\n==========================================");
System.out.println("Increment of A results to : "+(++a));
System.out.println("Decrement of B results to : "+(--b));
System.out.println("\nTypeCasting the Operators\n================================");
float fa = a;
double db = b;
System.out.println("Float value of a is : "+fa);
System.out.println("Double value of b is : "+db);
System.out.println("\nConditional Operators\n================================");
System.out.println("Max value of A or B is : "+max);
}
}