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);
        }
    }
}









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
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
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 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
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-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
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
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
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
automorphic numbers
automorphic numbers  how to find automorphic number in java   Hi Friend, Pleas visit the following link:ADS_TO_REPLACE_1 Automorphic numbers Thanks
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
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
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   
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
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
Struts 2 Format Examples
Struts 2 Format Examples       In this section you will learn how to format Date and numbers in Struts 2 Framework. Our Struts 2 Format Examples are very easy to grasp and you will learn these concepts
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"><
how to add to numbers in java
how to add to numbers in java  how to add to numbers in java
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
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
defining numbers in Java Script
defining numbers in Java Script  Explain about defining numbers in Java Script
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
Prime Numbers - IDE Questions
Prime Numbers  Create a program that calculates the prime numbers... numbers in rows of 10. Hint: Use a counter to count how many values are printed... = 0; System.out.println("Prime Numbers are:" ); for (int i = 1; i <
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
numbers divisible by 5 and 6
numbers divisible by 5 and 6  Find the first ten numbers which are greater than Long.MAX_VALUE divisible by 5 and 6
Java Query divide frame into 3 rows and 3 columns
Java Query divide frame into 3 rows and 3 columns  how can we divide the frame into 3 rows and 3 columns
Java divide method example
Java divide method example       In this example Java bigdecimal class divide (BigDecimal... = this.object.divide(divisor, mc); Java_BigDecimal_divide_BigDecimal_divisor
Perfect Numbers - Java Beginners
+ 2 + 3 Write a java program that finds and prints the three smallest perfect numbers. Use methods   Hi Friend, Try the following code: public
prime numbers - Java Beginners
prime numbers  Write a java program to find the prime numbers between n and m
Adding two numbers
Adding two numbers  Accepting value ffrom the keyboard and adding two numbers
Generate Random Numbers
Generate Random Numbers  hi,,, Please give me answer with example How do you generate random numbers within a given limit with actionscript... This function generate random numbers with in given limit
random numbers - Java Beginners
random numbers  write a program to accept 50 numbers and display 5 numbers randomly  Hi Friend, Try the following code: import...); System.out.println("Enter 10 numbers: "); for(int i=0;i<10;i
Find HCF of three numbers in Java Program
Enter Number 2: 14 Enter Number 3: 28 HCF of three numbers 7,14...Find HCF of three numbers in Java Program In this java tutorial section, you... Common Divisor) of three numbers. As you already know that HCF or GCD 
Generate array of random numbers
:ADS_TO_REPLACE_1 Enter 10 numbers: 1 2 3... Numbers are: 4 8 6 2 9...Generate array of random numbers You can generate a random number either
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
recursion numbers - Java Beginners
recursion numbers  I need to use recursion to test all values from 0 to 20 and see if they are contain in a 1-D array with values: 2,4,6,8,10,12,14,16,18,20. The results of all numbers from 0-20 will be printed
Sum of positive and negative numbers
; import java.util.*; class Numbers { public static void main(String...=0,sum2=0; int num[]=new int[10]; System.out.println("Enter 10 numbers...]; } } System.out.println("Sum of positive numbers: "+sum2); System.out.println
Applet for add two numbers
numbers?   import java.awt.Graphics; import javax.swing.*; public...); add(text2); label3 = new Label("Sum of Two Numbers...+num2; output.setText(Integer.toString(sum)); } } 2
Sum of first n numbers
Sum of first n numbers  i want a simple java program which will show the sum of first n numbers....   import java.util.*; public class...; } System.out.println("Sum of Numbers from 1 to "+n+" : "+sum
random numbers - Java Beginners
to display the random numbers, but not twice or more. I mean i need a number to be display once. This code allows some numbers to be displayed more than once. Hi... Scanner(System.in); System.out.println("Enter 10 numbers: "); for(int i=0;i<10;i

Ads