Access modifiers

Multiplication of two floating-point numbers using method in Java

Multiplication of two floating-point numbers using method in Java

In this tutorial, we will discuss the concept of Multiplication of two floating-point numbers using method in Java

In this topic, we are going to learn how to multiply two floating-point numbers using the method in Java language

Multiplication of two floating-point numbers

What is multiplication

The multiplication is a method of combining a group of equal size. The multiplication is an arithmetic operation inverse of division

It is one of the four basic operation of arithmetic calculation others being addition,subtraction,division

The multiplication of two  numbers means, it is the operation one number is combining within another using multiply(*) operator.

 

The answer of a multiplication operation is called as “product”

 

Program to multiply of two floating-point numbers in Java

Program to find product of two  numbers

The program calculates the product of the given two floating – point numbers using method in Java language

Program 1

//Multiply two float numbers in Java
public class MultiplyTwofloatmethod1{
public static void main(String args[]){
    float num1=4.6f;//variable declaration and initailization
    float num2=3.4f;
calc_Product(num1,num2);//Calling the method to produce output
}
public static void calc_Product(float x, float y){//Method definition
float result=x*y;//calculate the multiplication
System.out.println("Multiplication of "+x+" and "+y+" is:"+result);
//display the output
}
}

When the above code is executed, it produces the following result

Multiplication of 4.6 and 3.4 is: 15.64

 

Program to find product of two  numbers using method- input from user

The program allows the user to enter two floating-point numbers and then it calculates the multiplication of the given numbers using method in Java language

Program 2

//Multiply two float numbers in Java
import java.util.*;
public class MultiplyCalcTwofloatmethod{
public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
    //scanner class for input
System.out.println("Please Enter the first float number ");
float num1=sc.nextFloat();
System.out.println("Please Enter the second float number ");
float num2=sc.nextFloat();
calc_Product(num1,num2);//Calling the method
}
public static void calc_Product(float x, float y){//method definition
float result=x*y;//calculate the multiplication
System.out.println("Multiplication of "+x+" and "+y+" is:"+result);
//display the output
}
}

When the above code is executed, it produces the following result

Please enter the first float number
3.5
Please enter the second float number
5.4
Multiplication of 3.5 and 5.4 is: 18.9

 

Suggested for you

Operator in Java

Data types and variable in Java

 

Similar post

Find product of two numbers using method in Java

Find product of two numbers using recursion in Java

Multiply two numbers in C language

Multiply two numbers in C++ language

Multiply two numbers in Python language

Multiply two numbers in Java language

 

Multiply of two floating-point numbers in Java

Multiply of two floating-point numbers in C

Multiply of two floating-point numbers in C++

Multiply of two floating-point numbers in Python

Multiply of two floating-point numbers in Java using Method

Multiply of two floating-point numbers in C using function

Multiply of two floating-point numbers in C++ using function

Multiply of two floating-point numbers in Python using function

 

Calculate product of two floating point numbers in Python
Python code to multiply two floating-point numbers using function
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

PHP Star Triangle pattern program

PHP Star Triangle pattern program In this tutorial, we will discuss about PHP Star Triangle…

2 months ago

PHP Full Pyramid pattern program

PHP Full Pyramid pattern program In this tutorial, we will discuss about PHP Full Pyramid…

2 months ago

5 methods to add two numbers in Java

5 methods to add two numbers in Java In this tutorial, we will discuss the…

2 months ago

Python Full Pyramid star pattern program

Python full Pyramid star pattern program In this tutorial, we will discuss  the concept of…

5 months ago

Write a function or method to convert C into F -Entered by user

Write a function or method to convert C into F -Entered by the user In…

10 months ago

How to write a function or method to convert Celsius into Fahrenheit

How to write a function or method to convert Celsius into Fahrenheit In this tutorial,…

10 months ago