- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConditionExample2.java
More file actions
Latest commit
28 lines (22 loc) · 577 Bytes
/
Copy pathConditionExample2.java
File metadata and controls
28 lines (22 loc) · 577 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
/* Computer Programming 1
condition example 2
*/
importjava.io.*;
importjava.util.*;
publicclassConditionExample2
{
publicstaticvoidmain(String[] args) {
Scannerread = newScanner(System.in);
intx,y,z;
x = read.nextInt();
y = read.nextInt();
//two-way condidtion statement
//when deviding two numbers, we check whether or not the divisor != 0
if(y != 0){
z = x/y;
System.out.println("x/y=" + z);
}else{
System.out.println("Not Possible to divide by zero");
}
}
}