Java Program to Round Off the Decimal Number Using the Library Method

You are currently viewing Java Program to Round Off the Decimal Number Using the Library Method

Java program to round off the decimal number using the library method

// Java program to round off the decimal number 
// using the library method

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner X = new Scanner(System.in);

    double num = 0;

    System.out.print("Enter number: ");
    num = X.nextDouble();

    System.out.print("Number after round off: " + Math.round(num));
  }
}

Output

Enter number: 34.567
Number after round off: 35

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply