import java.util.Scanner;
public class MultiplyFloats {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the first floating point number: ");
float num1 = scanner.nextFloat();
System.out.print("Enter the second floating point number: ");
float num2 = scanner.nextFloat();
float product = num1 * num2;
System.out.println("The product of " + num1 + " and " + num2 + " is " + product);
}
}
Enter the first floating point number: 2.7
Enter the second floating point number: 3.6
The product of 2.7 and 3.6 is 9.72
Scanner
class to read two floating point numbers input by the user. We then multiply the two numbers together and store the result in a variable called product
. Finally, we print out a message displaying the values of the two numbers and the product of the two numbers.