I am trying to write a java program that rounds to one decimal place less. For example if I have a total of 32.45678 it should be 32.4568 or if its 0 it should be 0.0. Here is what I have so far. Thanks
import java.text.DecimalFormat;
import java.util.Scanner;
public class product{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter the first number:");
float f1 = scan.nextFloat();
System.out.println("Enter the second number:");
float f2 = scan.nextFloat();
float p = f1*f2;
DecimalFormat df = new DecimalFormat(".####");
System.out.println("Product: "+df.format(p));
}
}