Math round java

后端 未结 3 1634
悲哀的现实
悲哀的现实 2020-12-06 17:56

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

import java.util.Scanner;  

public class Centimer_Inch
{

pub         


        
3条回答
  •  猫巷女王i
    2020-12-06 18:25

    You can print to two decimal places using the following.

     System.out.printf("%.2f inch is %.2f centimeters%n", inches, centimeters);
    

提交回复
热议问题