forum

Home / DeveloperSection / Forums / Rounding a double in java

Rounding a double in java

Anonymous User187005-Oct-2013

I got project do convert from cm to inch. I did it: how can i round my number with Math.round? 

public class Centimer_Inch 
{
public static void main (String[] args)
{
        // 2.54cm is 1 inch
       Scanner cm = new Scanner(System.in); //Get INPUT from pc-Keyboard
       System.out.println("Enter the CM:"); // Write input
       double centimeters = cm.nextDouble();
       double inches = centimeters/2.54;
       System.out.println(inches + " Inch Is " + centimeters + " centimeters");
     }
}

Updated on 05-Oct-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By