Java Program to Multiply Two Numbers

Tutorialsrack 19/04/2021 Java

In this Java program, you’ll learn how to multiply two numbers in java. After performing the addition, the final sum is displayed on the display. To understand how to use a scanner class to take user input, check out this program: Program to read integers from system input.

Java Program to Multiply Two Numbers

Java Program to Multiply Two Numbers
//Java Program to Multiply Two Numbers

import java.util.Scanner;

public class JavaPrograms {

	public static void main(String[] args) {

		 * This reads the input provided by user using keyboard
		Scanner scan = new Scanner(System.in);
		System.out.print("Enter first number: ");

		// This method reads the number provided using keyboard
		int num1 = scan.nextInt();

		System.out.print("Enter second number: ");
		int num2 = scan.nextInt();

		// Closing Scanner after the use

		// Calculating product of two numbers
		int product = num1 * num2;

		// Displaying the multiplication result
		System.out.println("Output is: " + product);


Enter first number: 2

Enter second number: 111

Output is: 222

Related Posts


Recent Posts