Java: Display the product of two numbers
Product of Two Numbers
Write a Java program that takes two numbers as input and displays the product of two numbers.
Test Data:
Input first number: 25
Input second number: 5
Pictorial Presentation:

Sample Solution-1
Java Code:
Explanation:
The above Java code takes two integer numbers as input from the user, multiplies them, and then displays the result in the format "num1 x num2 = result." It uses the "Scanner" class to read user input and performs multiplication on the input values.
Sample Output:
Input first number: 25 Input second number: 5 25 x 5 = 125
Flowchart:

Sample Solution-2
Java Code:
Sample Output:
125
Flowchart:

For more Practice: Solve these Related Problems:
- Write a program that multiplies three numbers instead of two.
- Multiply two numbers without using the '*' operator.
- Write a program that multiplies a number by itself n times (exponentiation).
- Modify the program to accept floating-point numbers and print the product.
Java Code Editor:
Previous: Write a Java program to print the result of the specified operations.
Next: Write a Java program to print the sum (addition), multiply, subtract, divide and remainder of two numbers.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics