Write a java program to divide 2 numbers. Avoid division by zeor by catching the exception.

View Answers

March 20, 2012 at 3:00 PM

class Divide { public static void main(String[] args) { try{ int num1=8; int num2=4; int div=num1/num2; System.out.println(div); } catch(Exception e){ System.out.println(e); } } }

Ads

Related Tutorials/Questions & Answers:

Divide 2 numbers Write a java program to divide 2 numbers. Avoid division by zeor by catching the exception. class Divide { public static void main(String[] args) { try{ int num1=8

this code gives addition of 2 numbers in j2me..but the code is not executing ..can u pls find out the error...?? import javax.microedition.midlet....=new Form("Addtion of two numbers"); // result=new Command("Result

Advertisements

multiplication algorithms in java divide and conquer I need multiplication algorithms in java divide and conquer ask from user input two numbers... divide and conquer? Thanks All

multiplication algorithms in java divide and conquer I need multiplication algorithms in java divide and conquer ask from user input two numbers... divide and conquer? Thanks All

multiplication algorithms in java divide and conquer I need multiplication algorithms in java divide and conquer ask from user input two numbers... divide and conquer? Thanks All

divide a page how to divide a page using jsp in three different column and in which , in first column , there is a phone number box,whenever a phone numhber is given immediately it will shown in below of the phone box

divide a page how to divide a page using jsp in three different column and in which , in first column , there is a phone number box,whenever a phone numhber is given immediately it will shown in below of the phone box

ModuleNotFoundError: No module named 'divide' Hi, My Python... 'divide' How to remove the ModuleNotFoundError: No module named 'divide'... to install padas library. You can install divide python with following command

ModuleNotFoundError: No module named 'divide' Hi, My Python... 'divide' How to remove the ModuleNotFoundError: No module named 'divide'... to install padas library. You can install divide python with following command

Listing all even numbers between two numbers Hi, How to write code to list all the even numbers between two given numbers? Thanks Hi, You function will take 2 numbers and the find the even numbers between

Numbers pyramid Hi sir, Can you please tell me how to output this using nested for loops? 1 2, 1 1, 2, 3 4, 3, 2, 1 1, 2, 3, 4, 5 6, 5, 4, 3, 2, 1 1, 2, 3, 4, 5, 6, 7 8, 7, 6, 5, 4, 3, 2, 1 1, 2, 3, 4, 5, 6, 7, 8, 9 10, 9, 8

divide the line in to two In| this |example |we| are| creating |an |string| object| .We| initialize| this| string |object| as| "Rajesh Kumar"|.| We| are| taking| sub| string | In above mentioned line based on the tag i want

ModuleNotFoundError: No module named 'divide-and-cover' Hi, My... named 'divide-and-cover' How to remove the ModuleNotFoundError: No module named 'divide-and-cover' error? Thanks Hi, In your

ModuleNotFoundError: No module named 'divide-seq' Hi, My Python... 'divide-seq' How to remove the ModuleNotFoundError: No module named 'divide-seq' error? Thanks Hi, In your python environment you

Application for print pyramid of numbers What is the code for printing the numbers like 1 1 1 1 2 2 1 1 3 4 3 1 1 4 7 7 4 1

odd numbers with loop get the odd numbers till 100 with for,while loop Java find odd numbers: class OddNumbers { public static...++){ if(i%2!=0){ System.out.println(i

sorting numbers How to sort the numbers in ascending order import java.util.*; class SortNumbers{ public static void main(String...=input.nextInt(); list.add(num); } System.out.println("Numbers

Prime Numbers Create a complete Java program that allows the user to enter a positive integer n, and which then creates and populates an int array with the first n prime numbers. Your program should then display the contents

Rational Numbers Write and fully test a class that represents rational numbers. A rational number can be represented as the ratio of two integer values, a and b, where b is not zero. The class has attributes for the numerator

Need to have numbers printed like this 1 2 0 2 3 0 0 0 3 4 0 0

how to divide 1 web page into some parts... how to divide 1 web page... home page,bt m nt knowing how to divide that into frames in jsp. <...-width:2;"> <img src="C:\\image.jpg" height="100" width="1024"><

how to divide 1 web page into some parts... how to divide 1 web page... home page,bt m nt knowing how to divide that into frames in jsp. <...-width:2;"> <img src="C:\\image.jpg" height="100" width="1024"><

ModuleNotFoundError: No module named 'pytest-divide-and-cover' Hi...: No module named 'pytest-divide-and-cover' How to remove the ModuleNotFoundError: No module named 'pytest-divide-and-cover' error? Thanks

Hexadecimal numbers multiplication Sir, I have to multiply 128 bit hexadecimal numbers. Do u have any logic for this?? The numbers are like ab7564fa342b5412c34d9e67ab341b58

ModuleNotFoundError: No module named 'numbers' Hi, My Python... 'numbers' How to remove the ModuleNotFoundError: No module named 'numbers... to install padas library. You can install numbers python with following command

use is of 2 why we use 2 in "Integer.parseInt(str,2);" for binary to decimal conversion..?? ya i got it... because binary contain only two o and 1...so here use 2...same as octal has 8

multiply of 100 digits numbers multiplying 100 digits numbers to eachother

address1 and address 2 validation Hi sir/Madam, I m doing One Project Quite now. I would like to validate address that comprises of door numbers,street name, area name .Please provide java-script to do the same.Thanks in advance