Ardana F. answered 10/10/22
Versatile Tutor specializing English and Computer Science
// importing Scanner library to read in user input
import java.util.Scanner;
public static void multiply() {
// surrounding code with try/catch, to catch possible errors thrown when reading in user input
try {
Scanner input = new Scanner(System.in);
// reading in doubles because the double type allow for integers and floats.
System.out.println("Please enter your first number: ");
double a = input.nextDouble();
System.out.println("Please enter your second number: ");
double b = input.nextDouble();
double product = a * b;
System.out.println("The product of your two numbers is "+ product);
}
catch (Exception e) {
System.err.println(e.getMessage());
}
}