Round the value of Given number in Java

import java.util.Scanner;

public class abc {

    public static void main(String[] args) {
        Scanner myScanner=new Scanner(System.in);
        float num;
        System.out.print("Enter the number : ");
        num=myScanner.nextFloat();
       
        float ans=Math.round(num);
        System.out.println("The digit count is : "+ans);
    }

}
//Enter the number : 11.50
//The digit count is : 12.0

Share this

Related Posts

Previous
Next Post »