-->

Hello,This is me!

ITEngineer8995

Professional Coder Coding is my passion

Saturday, May 9, 2020

Java Program to Multiply Two Integer Numbers

  • May 09, 2020
  • by


Java Program to Multiply Two Integer Numbers


In this Java Program, we perform multiplication of the two integer numbers.


Logic : int c = int a * int b


Step 1 : Import java.util.Scanner.


Step 2 : Ask the user to enter the first number by using System.out.print method.


Step 3 : Store the user entered number in the variable num1.


Step 4 : Ask the user to enter the second number by using System.out.print method.


Step 5 : Store the user entered number in the variable num2.


Step 6 : Close the Scanner to avoid memory leak.


Step 7 : Calculate the product of the two numbers by using * operator and store the product in the variable product.


Step 8 : Display the result by using System.out.print.


Program :


import java.util.Scanner;


public class Multiply

        {

            public static void main(String[] args)

            {

               

                //This reads the input provided by user using keyboard

               

                Scanner sc = new Scanner(System.in);

                System.out.print("Enter first number:");

               

                //This method reads the number provided using keyboard

                int num1 = sc.nextInt();

               

                System.out.print("Enter second number:");

                int num2 = sc.nextInt();

               

                //Closing Scanner after the use

                sc.close();

               

                //Calculating product of two numbers

                int product = num1*num2;

               

                //Displaying the multiplication result

                System.out.println("Output:"+product);

               

            }


}



OUTPUT:


Enter first number : 15

Enter second number : 6

Output : 90


For execution of the same do visit my YouTube Channel:


A blog full of codes of various languages like Java, .net, C, C++ etc with their outputs and some other IT stuff.

0 comments:

Post a Comment

ITEngineer8995
India

SEND ME A MESSAGE

Search This Blog

Powered by Blogger.

Pages