Divide 2 numbers

Divide 2 numbers

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
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...??
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
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
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
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
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
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 html page
divide html page   how to divide html page into 3 parts without using frames
ModuleNotFoundError: No module named 'divide'
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'
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
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
divide the line in to two
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'
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'
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
Numbers pyramid
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
sorting numbers
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
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
odd numbers with loop
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
Rational Numbers
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
Application for print pyramid of numbers
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
ModuleNotFoundError: No module named 'pytest-divide-and-cover'
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   
how to add to numbers in java
how to add to numbers in java  how to add to numbers in java
Hexadecimal numbers multiplication
Hexadecimal numbers multiplication  Sir, I have to multiply 128 bit hexadecimal numbers. Do u have any logic for this?? The numbers are like ab7564fa342b5412c34d9e67ab341b58
Addition of two numbers
Addition of two numbers  addition of two numbers
how to divide 1 web page into some parts...
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 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 'numbers'
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
multiply of 100 digits numbers
multiply of 100 digits numbers  multiplying 100 digits numbers to eachother
how to divide a web page into some frames.....
how to divide a web page into some frames.....  how to divide 1 web page into some parts. i know it using frames in html,bt how can we do it in jsp... page,bt m nt knowing how to divide that into frames in jsp.  Please go
Adding two numbers
Adding two numbers  Accepting value ffrom the keyboard and adding two numbers
Need to have numbers printed like this
Need to have numbers printed like this   1 2 0 2 3 0 0 0 3 4 0 0

Ads