Answer:
- public class Main {
- public static void main(String[] args)
- {
- Scanner input = new Scanner(System.in);
-
- System.out.print("Enter a floating point value: ");
- double value = input.nextDouble();
-
- System.out.println(Math.floor(value));
- System.out.println(Math.ceil(value));
- }
- }
Step-by-step explanation:
Firstly create a Scanner object (Line 4).
Next, prompt the user to enter a floating point value and assign it to variable value (Line 6 -7).
Use the Java Math floor and ceil method to get the number less than and greater then the value, respectively, and print them out to the console (Line 9 - 10).