Java Function which receives a float and an int from main(), finds the product of these two and returns the product which is printed through main().

//Java Function which receives a float and an int from main(), finds the product of these two and returns the product which is printed through main().


import java.util.Scanner;

public class Program 
{   
    	public static void main( String[] args ) 
    	{
		Scanner reader = new Scanner(System.in);
		float a, p;
		int b;
		System.out.print("\nEnter Float Value :");
		a = reader.nextFloat();
		System.out.print("\nEnter Integer Value :");
		b = reader.nextInt();
		p = product(a,b);
		System.out.print("\nThe product is " + p);
   	}
   	public static float product(float i, int j)
   	{
		
    		float pr;
		pr = i*j;
		return pr;
   	}
	
}

Output :
Enter the two values to find the product(float x int): 25.5
2

The product is 51.00



Leave a comment