Java program for down rounding a number

Java program for rounding a number

Java program for down rounding a decimal.

Java program for rounding a decimal.

Program:-

import java.util.Scanner;

class group{
public static void main(String angt[]){
Scanner data = new Scanner(System.in);
double num;
System.out.println("Enter a number");
num=data.nextDouble();

num=Math.floor(num);
System.out.println("Answer:"+num);


}
}


Output:-

Enter a number
2.5
Answer:2.0

Output:-

Enter a number
2.2
Answer:2.0

Output:-

Enter a number
2.8
Answer:2.0




Learn Java:-
Java codes

Java Programs:-
List of Java Programs

Leave reply

Add your comments here

Back to Top