Java Program to Multiply two Floating-Point Numbers

Last Updated : 4 Aug, 2026

In Java, floating-point numbers (float and double) are used to represent decimal values. Multiplying two floating-point numbers is a simple arithmetic operation performed using the * operator. The result is stored in another floating-point variable and can be displayed using System.out.println().

  • Supports decimal values using the float data type.
  • The result is stored in another float variable.

Illustration

Input: f1 = 1.5, f2 = 2.0
Output: The product is: 3.0

Input: f1 = 3.2, f2 = 4.5
Output: The product is: 14.4

Approach

  • Initialize two float variables.
  • Multiply them using the * operator.
  • Store the result in another float variable.
  • Print the multiplication result.

Example: Program to print Multiplication of two floating point Number.

Java
import java.io.*;

class GFG {
    public static void main(String[] args)
    {

        // f is to ensures that numbers are float DATA TYPE
        float f1 = 1.5f;
        float f2 = 2.0f;

        // to store the multiplied value
        float p = f1 * f2;

        // to print the product
        System.out.println("The product is: " + p);
    }
}

Output
The product is: 3.0

Explanation: In this example, two floating-point numbers (1.5f and 2.0f) are initialized using the float data type. Their product is calculated using the * operator, stored in a float variable, and then printed to the console.

Comment