In this Program the user is asked to enter two numbers. Based on the numbers the division of two numbers is per

Algorithm:

Step 1: Start.

Step 2: Declare variables, say a, b and c.

Step 3: c = a/b;

Step 4: Display result.

Step 5: Stop.

Source code:

import java.util.Scanner;
class Division
{
	public static void main(String args[])
	{
		int num1;
		int num2;
		float result;
		System.out.println("\n \n *** www.programmingposts.com *** \n \n");
    		System.out.println("<< JAVA Program for division Two Integers >> \n \n");
		Scanner scanner = new Scanner(System.in); 
		System.out.println("Enter first number:");
		num1 = scanner.nextInt();
		System.out.println("Enter Second number:");
		num2 = scanner.nextInt();
		result = num1 / num2;
		System.out.println("The division of two numbers is:" +result); 		
	}
}

Output:

C:\Users\santo\Desktop\new>javac Division.java

C:\Users\santo\Desktop\new>java Division

*** www.programmingposts.com ***

<< JAVA Program for division Two Integers >>

Enter first number:

10

Enter Second number:

5

The division of two numbers is:2.0

Screenshot of Output:

Screenshot of output

 

Leave a Reply

Your email address will not be published. Required fields are marked *