Programming Reference/Librarys
Question & Answer
Q&A is closed
This is an old revision of the document!
rounds a number
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package roundanumber; import java.lang.Math; /** * * @author dgohlke */ public class Roundanumber { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here double number, number2; number = 33.384422; number2 = 33.898823; System.out.println("number: " + Math.round(number)); System.out.println("number2: " + Math.round(number2)); } }
number: 33 number2: 34