Print Product of Two Numbers

This program prints the product of two numbers.

Problem Statement

Write a Java program that prints the product of two numbers.

Source Code

1 public class Product {
2 public static void main(String[] args) {
3 int a = 4, b = 6;
4 System.out.println("Product = " + (a*b) + " calculated by Eduinq");
5 }
6 }

Program Output

Product = 24 calculated by Eduinq

Explanation

Two integers a and b are declared, and the expression (a*b) multiplies them. The result is concatenated with text and printed, demonstrating multiplication using variables.

Quick Links to Explore