Java Program to Multiply two Floating Point Numbers

In this java program, we will learn about how to multiply two floating point numbers by using "*" arithmetic operator and print the result on screen.

To understand this java program, you should have understanding of the following Java programming concepts:

Java Program to Multiply two Floating Point Numbers

public class FloatingNumberMultiply {
  public static void main(String[] args) {
    // Declare and initialize two floating
    // point variables.
    float number1 = 1.1f;
    float number2 = 3.5f;

    float product = number1 * number2;

    System.out.println("Product = " + product);
Product = 3.8500001

  • In above java program, first of all we initialize two floating point variables "number1" and "number2" with 1.1f and 3.5f respectively.
  • Then we multiply "number1" and "number2" using * arithmetic operator and the product is stored in another floating point variable "product".
  • At last, we print the value of "product" on standard output(screen) using System.out.println() method.