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

In this Java program, we will learn how to find the GCD of two numbers using Java.  GCD (Greatest Common...
  • Java
  • December 3, 2024
In this Java Program, you’ll learn how to swap two numbers using the Java programming language.  How to Swap Two...
  • Java
  • December 2, 2024
In this Java program , we will learn how to Find Largest Element in an Array in your Java program.   How to Find Largest Element...
  • Java
  • December 2, 2024