-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtryCatch.java
More file actions
27 lines (27 loc) · 799 Bytes
/
Copy pathtryCatch.java
File metadata and controls
27 lines (27 loc) · 799 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
package programs;
import java.util.Scanner;
public class tryCatch {
public static void main(String []args) {
Scanner sc=new Scanner(System.in);
char choice='y';
while(choice=='y') {
try {
System.out.println("Program to perform Division");
System.out.println("Enter no 1");
int number1=sc.nextInt();
System.out.println("Enter no 2");
int number2=sc.nextInt();
int result=number1/number2;
System.out.println("Result="+result);
}
catch(ArithmeticException e) {
System.out.println("Division by Zero is not possible");
}
finally {
System.out.println("End of Operation");
}
System.out.println("Do you want to continue y or n");
choice=sc.next().charAt(0);
}
}
}