You are on page 1of 4

Object Oriented Programming (BCA202)

An Object Oriented Programming Lab report submitted in partial fulfillment


of the requirements for the degree of BCA

Submitted by
Name: Syeda Farheen
Roll No: 20201BCA0067

Laboratory Instructor
Mr.B. Prabhu Shankar

Department of Computer Science and Engineering


PRESIDENCY UNIVERSITY, BANGALORE
Karnataka- 560064, India
LAB-12
Shyam’s teacher asked him to submit an assignment on division of integers, he wrote a java
program to complete the assignment, his program abruptly ended at a condition. Identify the
condition where Shyama program abruptly ended and handle the condition using suitable
measures.

Procedure:

1. Deinde the class exception handling with try and catch block
witharithmeticException in the catch block of the resp[ective try statement.
2. When the user try to give the divisor value as 0. It will end up as an
exceptionalstatement.
Tools Used
JDK / Eclipse/ Netbeans / notepad++ / online java compiler
import java.util.*; class

exceptionhandling {

public static void main(String args[])

int a,b,res;

System.out.println("Enter the Number a");

System.out.println("Enter the Number b");

Scanner sc=new Scanner(System.in);

a=sc.nextInt(); b=sc.nextInt(); try

res=a/b;

System.out.println("THe Result is"+res);

} catch(ArithmeticException

e)

System.out.println("Division by Zero Error")

}
OUTPUT

You might also like