Future Vision BIE Future Vision BIE


ONE STOP FOR ALL STUDY MATERIALS & LAB PROGRAMS


E MENU Whatsapp Share Join Telegram, to get Instant Updates
× NOTE! Click on MENU to Browse between Subjects...

Advertisement

DESIGN AND ANALYSIS OF ALGORITHMS LABORATORY

(Effective from the academic year 2018 -2019)

SEMESTER - IV

Course Code 18CSL47

CIE Marks 40

Number of Contact Hours/Week 0:2:2

SEE Marks 60

Total Number of Lab Contact Hours 36

Exam Hours 03



Experiments 3 A

Write a Java program to read two integers A and B. Compute a/b and print, when b is not zero. Raise an exception when b is equal to zero.



Advertisement


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
//package threeA;
import java.util.Scanner;
public class Exception {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a,b,c;
		System.out.print("Enter the Two Interger Values\nA :");
		a=scan.nextInt();
		System.out.print("B :");
		b=scan.nextInt();
		scan.close();
		try {
			if(b==0)
				throw new ArithmeticException("Divide By Zero");
			c=a/b;
			System.out.println("\nThe Value of "+a+" / "+b+" is "+c);
		}catch(ArithmeticException e)
		{
			e.printStackTrace();
		}
	}
}

Advertisement

output
Fig 3.1: Output .

Advertisement
output
Fig 3.2: Output .

× Note Please Share the website link with Your Friends and known Students...

-ADMIN

× Note Page Number is specified to navigate between Pages...
T = Text book
QB = Question Bank
AS = Amswer Script


-ADMIN

Advertisement