-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasicOperators.java
More file actions
28 lines (23 loc) · 839 Bytes
/
BasicOperators.java
File metadata and controls
28 lines (23 loc) · 839 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
25
26
27
28
package basicoperators;
import java.util.Scanner;
public class BasicOperators {
public static void main(String[] args) {
// Demonstrates basic arithmetic operators
Scanner input = new Scanner(System.in);
int x,y, result;
System.out.print("Enter value for X : ");
x = input.nextInt();
System.out.print("Enter value for Y : ");
y = input.nextInt();
result = x + y;
System.out.printf(" X + Y = %d\n", result );
result = x - y;
System.out.printf(" X - Y = %d\n", result );
result = x * y;
System.out.printf(" X * Y = %d\n", result );
result = x / y;
System.out.printf(" X / Y = %d\n", result );
result = x % y;
System.out.printf(" X mod Y = %d\n", result );
}
}