A Program That Uses the Rounding Methods of the Math Class
public class MainCLass { public static void main(String[] args) { double x = 2.4; double y = 9.5; double z = -1.3; System.out.println("round(x) = " + Math.round(x)); System.out.println("round(y) = " + Math.round(y)); System.out.println("round(z) = " + Math.round(z)); System.out.println(); System.out.println("ceil(x) = " + Math.ceil(x)); System.out.println("ceil(y) = " + Math.ceil(y)); System.out.println("ceil(z) = " + Math.ceil(z)); System.out.println(); System.out.println("floor(x) = " + Math.floor(x)); System.out.println("floor(y) = " + Math.floor(y)); System.out.println("floor(z) = " + Math.floor(z)); System.out.println(); System.out.println("rint(x) = " + Math.rint(x)); System.out.println("rint(y) = " + Math.rint(y)); System.out.println("rint(z) = " + Math.rint(z)); } }