Round the given number to nearest multiple of 10 | Java Code for Round the given number to nearest multiple of 10 ; function to round the number ; Smaller multiple ; Larger multiple ; Return of closest of two ; Driver program to test above function
import java . util . * ; class GFG { static int round ( int n ) { int a = ( n / 10 ) * 10 ; int b = a + 10 ; return ( n - a > b - n ) ? b : a ; } public static void main ( String [ ] args ) { int n = 4722 ; System . out . println ( round ( n ) ) ; } }