Write a Java Program to Multiply Two Floating-Point Numbers

January 23, 2023 0 Comments

In this tutorial learn how you can write a program to multiply two floating-point numbers in java. We can use both float and double classes.

Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible.

Write a Program to Multiply Two Floating-Point Numbers in Java

Here is the code to multiply two floating-point numbers in Java programming.

//Write a program to multiply two floating-point numbers.
import java.util.Scanner;

public class Float {
    public static void main(String[] args) {
        float first_num, second_num, multiply;
        Scanner data = new Scanner(System.in);
        System.out.println("Enter the first number:");
        first_num = data.nextFloat();
        System.out.println("Enter the second number:");
        second_num = data.nextFloat();
        multiply = first_num * second_num;
        System.out.println("Multiplication of two floating point number is: " + multiply + ".");
        data.close();

    }
}

Test Live At Jdoodle

Conclusion

This is how you can write a program to multiply two floating-point numbers in java programming. Comment below if you like our tutorial.

Leave a comment

Gallery