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 SNIPPETpublic 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.