Here is the Java code.
- import java.util.Scanner;
- import java.io.*;
- public class CeilingFloor {
- public static void main(String[] args) throws Exception {
- BufferedReader br = new BufferedReader(new InputStreamReader(System. in ));
- System.out.println("1-Want demo of Ceiling value of a number..?");
- System.out.println("2-Want demo of Floor value of a number..?");
- System.out.println();
- System.out.print("Select any option: ");
- int select = Integer.parseInt(br.readLine());
- switch (select) {
- case 1:
- System.out.println("Here are some examples of Ceiling values: ");
-
- System.out.println("Ceiling value of 10 is: " + Math.ceil(10));
-
- System.out.println("Ceiling value of 10.1 is: " + Math.ceil(10.1));
-
- System.out.println("Ceiling value of 5.5 is: " + Math.ceil(5.5));
-
- System.out.println("Ceiling value of -20 is: " + Math.ceil(-20));
-
- System.out.println("Ceiling value of -42.4 is: " + Math.ceil(-42.4));
-
- System.out.println("Ceiling value of 0 is: " + Math.ceil(0));
- System.out.println("If you want to test some other numbers then,");
- System.out.print("Enter the number: ");
- Scanner in = new Scanner(System. in );
- float input = in .nextFloat();
- System.out.println("Ceiling value of " + input + " is: " + Math.ceil(input));
- break;
- case 2:
- System.out.println("Here are some examples of Floor values: ");
-
- System.out.println("floor value of 70 is: " + Math.floor(70));
-
- System.out.println("floor value of 30.1 is: " + Math.floor(30.1));
-
- System.out.println("floor value of 15.5 is: " + Math.floor(15.5));
-
- System.out.println("floor value of -40 is: " + Math.floor(-40));
-
- System.out.println("floor value of -42.4 is: " + Math.floor(-42.4));
-
- System.out.println("floor value of 0 is: " + Math.floor(0));
- System.out.println("If you want to test some other numbers then,");
- System.out.print("Enter the number: ");
- Scanner s = new Scanner(System. in );
- float input1 = s.nextFloat();
- System.out.println("Ceiling value of " + input1 + " is: " + Math.floor(input1));
- break;
- }
- }
- }
Thank you, keep learning and sharing.