Using the double data type for variables in Java and rounding to 2 decimal places (2dp).
public class Main {
public static void main(String[] args) {
// declare first number
double firstNum = 14.678;
// declare second number
double secondNum = 21.987;
// declare result variable and multiply values
double result = (firstNum * secondNum);
// round the result to 2 decimal places 2dp
double resultRounded = Math.round(result*100.0)/100.0;
// display the result to the console
System.out.println("The result was: " + resultRounded);
}
}