Java Program to divide two numbers

Description

Get two integer numbers, divide both the integers and dispaly the quotient.
Input 1:
6 5
Output1:
1
Input2:
28 4
Output2:
7

Solution

import java.util.*;
class Division
{
      public static void main(String args[])
      {
 
          int Input1,Input2,div;
          Scanner sc=new Scanner(System.in);

          System.out.println("Enter The  Input 1:");
          Input1=sc.nextInt();
          System.out.println("Enter The Input 2:");
          Input2=sc.nextInt();
          div=Input1/Input2;
          System.out.println("The Output Is:\n"+div);
       }

}

Explanation

Get two integers Input1 and Input2 (using scanner class)

Divide Input1 by Input2, then store quotient in div (div=Input1/Input2, Note "/" operator gives quotient)

Print the value of div (using system.out.println)
Ramesh P Natarajan

Author - Ramesh P Natarajan

Learner, Professor, Technology Trainer, Software Developer and Content Marketer, very much passionate in the field of Software Application Development, Machine Learning and Search Engine Optimization.

Write to: admin@decodeschool.com





Interesting Pattern Programs: for more Patterns

Input:
5
Output:
*
**
***
****
*****
****
***
**
*Solution
Input:
5
Output:
    *
   ***
  *****
 *******
*********
 *******
  *****
   ***
    *Solution
Input:
5
Output:
*        *
**      **
***    ***
****  ****
**********Solution
Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********Solution
Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********
**** ****
***   ***
**     **
*       *Solution
Input:
5
Output:
*********
 *******
  *****
   ***
    *
   ***
  *****
 *******
*********Solution