-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp13.java
More file actions
35 lines (31 loc) · 835 Bytes
/
p13.java
File metadata and controls
35 lines (31 loc) · 835 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
29
30
31
32
33
34
35
/*
PROBLEM STATEMENT:-Write a program on template and exception handling in Java: in this assignment multiple
templates are to be designed as a pattern and these patterns to be used to take decisions.
*/
import java.util.Scanner;
class p13
{
public static void main(String[]args)
{
int a,b,result;
Scanner input=new Scanner(System.in);
System.out.println("Input two integers");
a=input.nextInt();
b=input.nextInt();
//try block
try
{
result=a/b;
System.out.println("Result=" + result);
}
//catch block
catch(ArithmeticException e)
{
System.out.println("Exception caught:Division by zero,");
}
finally
{
System.out.println("Exception Handling");
}
}
}