Please do the above program in Java Programming Language. Write a program that r
ID: 3752038 • Letter: P
Question
Please do the above program in Java Programming Language.
Write a program that reads a floating-point number as input from the console and then prints out the where it lies in terms of the closest integer above and below it You should use one or more methods from the Math class to implement your solution. You may also find it useful to use formatted output in your solution. You will need to be able to handle large inputs, so choose your data types appropriately. It's okay to assume that the input number would fit in a long if converted to an integer type·if the number the user enters is a whole number, you can just use that same number as both the bounds. Be sure to match the expected input/output format exactly and pass all the test cases. You should also use good style in your solution, structure your code in a readable way, and add implementation comments where appropriate. Example inputs/outputs: Enter a number: 1417.7 That is between 1417 and 1418 Enter a number: 248 That is between 248 and 248.Explanation / Answer
import java.util.Scanner;
class Main {
public static void main(String[] args) {
// Declaring varibles and taking user input
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number: ");
double number = sc.nextDouble();
// printing output
System.out.printf("That is between %.0f and %.0f", Math.floor(number), Math.ceil(number));
}
}
/*SAMPLE OUTPUT
Enter a number:
1417.7
That is between 1417 and 1418
Enter a number:
248
That is between 248 and 248
*/