Write a Java Program to Multiply Two Numbers

In this tutorial, we are going to see how to write a java program to multiply two numbers. The following program asks the user to enter two integers and displays the product. To understand how to use Scanner to get user input, See this tutorial: How to Get User Input in Java.

Java Program to Multiply Two Numbers:
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(;
        System.out.print("Enter the first number: ");

        // read the 1st number
        int nbr1 = scan.nextInt();
        System.out.print("Enter the second number: ");
        int nbr2 = scan.nextInt();
        // Calculate the product of the two numbers
        int res = nbr1 * nbr2;
        // Display the result
        System.out.println(nbr1 + " x "+ nbr2 + " = " + res);


Enter the first number: 2
Enter the second number: 3
2 x 3 = 6
mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

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