Home Answers Viewqa Java-Beginners Divide 2 numbers

 
 


Abhi
Divide 2 numbers
1 Answer(s)      a year and 2 months ago
Posted in : Java Beginners

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 Pages:
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
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
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
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"><
Find HCF of three numbers in Java Program
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  is the largest positive integer that can exactly divide each one of the number
Java: Method Exercises 2
; if (x%2 == 0) { result = x / 2; // If number is even, divide it by 2 } else { result = 3*x + 1; // Odd numbers processed here... Java: Method Exercises 2 Name: _________________________________ What
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
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
how to divide 1 web page into some parts using div tag...
how to divide 1 web page into some parts using div tag...  how to divide 1 web page into some parts. i know it using frames in html,bt how can we do... creating home page,bt m nt knowing how to divide that into frames in jsp
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 <
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
Programming: Prime Numbers - Dialog
numbers are integers which can not be divided evenly by any other integers except 1 and themselves. For example, some of the first prime numbers are 2, 3, 5, 7... Java NotesProgramming: Prime Numbers - Dialog Name
Java Pyramid of Numbers
: 1 2 1 2 3 2 1 2 3 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5
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
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
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
Generate array of random numbers
: Enter 10 numbers: 1 2 3 4 5...Generate array of random numbers You can generate a random number either...() but it is better to use Random class. If you want to generate a series of random numbers
EVEN NUMBERS - Java Interview Questions
EVEN NUMBERS  i want program of even numbers?i want source code plz... counter = 0; System.out.println("Even Numbers are:" ); for (int i = 1; i <=20; i++){ if (i % 2 == 0
Printing numbers up to N into a file
Printing numbers up to N into a file  I'd like to print the first N integers, that is, "1, 2, 3, 4, ..., N-1, N", say N equals 1000, or 10000 or whatever. I'd also like to have the result stored as a file instead of having
Random Numbers - shuffling
Java NotesRandom Numbers - shuffling A standard approach to shuffling the elements of an array is to write some code as described below. As of Java 2... is described at the bottom. Shuffling: Random numbers without replacement
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
divide html page
divide html page   how to divide html page into 3 parts without using frames
Write a program to list all even numbers between two numbers
numbers which are divided by the integer 2. In the end apply the catch exception... Write a program to list all even numbers between two numbers       Java Even Numbers - Even
Assigning ordinate numbers - JSP-Servlet
it as the 5th, 1 - print 1st, 2 - print 2nd, 3 -print 3rd, 4-10 print with "th...: return "st"; case 2: return "nd"; case 3: return "rd...) { case 1: return "st"; case 2: return "nd"; case 3: return
generating random numbers - Java Beginners
A weighting of .2,.2,.2,.2,.2 will exactly predict the only past price that had 5... + 1*50 = 10 which was exactly right. 2) {50,60,50,60,50,60,60
print the even numbers between the range 100-200
print the even numbers between the range 100-200  Q ?write an application that print out the even numbers between the range 100-200 ? 1- which aer not divisible by 7 and 5 ? 2- Number of the numbers which are not divisible
address1 and address 2 validation
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
help me 2
help me 2  write java program to enter five numbers and will determine the location of the number sample output: ENTER 5 NUMBERS: 1 2 3 4 5 ENTER NUMBER TO SEARCH:1{press enter} 1 found in index 0   import
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
Add Complex Numbers Java
How to Add Complex Numbers Java In this Java tutorial section, you will learn how to add complex Numbers in Java Programming Language. As you are already aware of Complex numbers. It is composed of two part - a real part and an imaginary
how I make the numbers in descending order ?
how I make the numbers in descending order ?   public class Quiz1...(System.in); int number [] = new int [20]; int num =2; for(int i =0; i<...)+":"); number[i]= sc.nextInt(); } System.out.print("the numbers
Java write even numbers to file
started a loop for numbers 1 to 50. If the number is totally divided by 2...Java write even numbers to file In this section, you will learn how to write the even numbers to file. By using the PrintWriter class, you can write any type
Printing numbers in pyramid format - Java Beginners
Printing numbers in pyramid format  Q) Can you please tel me the code to print the numbers in the following format: 1 2 3 4 5 6 7 8 9 10   Hi Friend, Try
JavaScript array of numbers
JavaScript array of numbers   ... in understanding 'Java Script array of numbers'. For this we use  Java... print the list of arrays of numbers.          
GUI 2 - Java Beginners
GUI 2  How can I modify this code? Please give me a GUI Example.Thanks!!  This can be done using KeyEvent in the following way... written... extends the text field to type numbers in to more than 4. I'll study the code
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
PHP Numbers Variables
PHP Variables Numbers We already define that variables are used to store the values or information in the form text strings, numbers or array. A variable... you can used again and again.  You can also assign numbers in PHP variable
Generate array of random numbers without repetition
numbers: 1 2 3 4 5 6 7 8 9 10 Generated Random Numbers: 10 1 2...Generate array of random numbers without repetition In the previous section
Swapping of two numbers
Swapping of two numbers      ... program to calculate swap of two numbers. Swapping is used where  you want... ability. In this program we will see how we can swap two numbers. We can do
Pick Prime Numbers from the ArrayList
are: 2 3 5 7 Non Prime Numbers are: 1...Pick Prime Numbers from the ArrayList Programmers mostly used ArrayList... and non prime numbers separately. Here is the code: import java.util.
write an application that print out the even numbers between the range 100-200
write an application that print out the even numbers between the range 100-200   write an application that print out the even numbers between... and determine the even numbers between them. class EvenNumbers { public static
arrays part 2 - Java Beginners
arrays part 2  Question 2: Useful Array Algorithms and Operations (5 marks) Upgrade the program in Question 1 so that the program includes...); System.out.println("Enter numbers: "); for(int i=0;i max) { max
JavaScript determine add, product of two numbers
("Sum of two numbers is: "+sum); } function divide...JavaScript determine add, product of two numbers In this section, you... numbers. To find this, we have created two textboxes and four button
Calculate sum of even and odd numbers in Java
Calculate sum of even and odd numbers In this section, you will learn how to read the file that contains even and odd numbers and calculate their sum separately. To do this, first of all, we have found all the even and odd numbers from 1
how to write a program in java to print numbers in equalateral triangle
how to write a program in java to print numbers in equalateral triangle ... of pattern 1 2 3 4 5 6 7 8 9 Example: public class NumberTriangle{ public static void main(String args[]){ int n=1; for(int i=1;i<=5;i=i+2

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.