Java Program to Multiply Two Floating Point Numbers

In this Java program, we’ll learn how to multiply two floating point numbers in Java

How to Multiply Two Floating Point Numbers in Java?

RUN CODE SNIPPET
public class Main { 

    public static void main(String[] args) { 

        float a = 5.5f; 

        float b = 5.5f; 

        float c = a * b; 

        System.out.println("The product is: " + c); 

    } 

}

Output 

The product is: 30.25

In the above program, the two floating points 5.5f is stored in variable a, and 5.5f is stored in a variable b. 

Here using the multiplication operator “*” a and b are multiplied and stored in a variable called c.the f after each number ensures that the number is float type. 

Using the println() function we print the result c on screen.  

Share:

Leave A Reply

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

You May Also Like

Java is a popular programming language that is used to develop a wide range of applications. If you are a...
  • Java
  • March 6, 2023
Java is a programming language and computing platform that is used to create various types of applications. It is used...
  • Java
  • March 6, 2023
In this post, you’ll learn how to download and install JUnit in Eclipse so that you can use in your...
  • Java
  • October 9, 2022