Java Program to multiply two Floating Point Numbers

by | Aug 19, 2021 | Java Programs

Home » Java » Java Programs » Java Program to multiply two Floating Point Numbers


The float class in Java acts as a wrapper class from the primitive datatype called float. This class contains several methods that are required to undergo float value manipulations. Some of those include converting float values to string representations, and vice-versa. A Float class object at a time can only hold one float value.

The program here tries to deal with two floating point numbers and prints out the result of the multiplication between the two.

Work Flow of the Program

  • The two float type numbers need to be initialized
  • A float variable needs to be initialized along with it. This will store the values of the multiplication result in the variable.
  • Finally print the result.


class Demo
public static void main (String args [])
float f1 = 1.5f;
float f2 = 2.0f;
float p = f1*f2;
System.out.println (“The product is: ” + p);


The product is: 3.0


Submit a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.