forum

home / developersection / forums / rounding a double in java

Rounding a double in java

Anonymous User 2114 05-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 !


Message
Can you answer this question?

Answer

1 Answers

Liked By