fork download
  1. import java.util.Scanner;
  2.  
  3. class MathTest
  4. {
  5. public static void main (String[] args)
  6. {
  7. int number1;
  8. double number2;
  9.  
  10. Scanner scanner = new Scanner(System.in);
  11.  
  12. System.out.print("Input integer value: ");
  13. number1 = scanner.nextInt();
  14. System.out.print("Input double value: ");
  15. number2 = scanner.nextDouble();
  16.  
  17. double squareRoot = Math.sqrt(number1);
  18. double randomNumber = Math.random() * number1;
  19. double floor = Math.floor(number2);
  20. double ceiling = Math.ceil(number2);
  21. long round = Math.round(number2);
  22. double larger = Math.max(number1, number2);
  23. double smaller = Math.min(number1, number2);
  24.  
  25. System.out.println("Square root of " + number1 + " is " + squareRoot);
  26. System.out.println("One random number between 0 and " + number1 + " can be " + randomNumber);
  27. System.out.println("Value of the floor of " + number2 + " is " + floor);
  28. System.out.println("Value of the ceiling of " + number2 + " is " + ceiling);
  29. System.out.println("Value of round of " + number2 + " is " + round);
  30. System.out.println("The larger value between " + number1 + " and " + number2 + " is " + larger);
  31. System.out.println("The smaller value between " + number1 + " and " + number2 + " is " + smaller);
  32.  
  33.  
  34.  
  35. }
  36. }
Success #stdin #stdout 0.23s 61844KB
stdin
10
2
stdout
Input integer value: Input double value: Square root of 10 is 3.1622776601683795
One random number between 0 and 10 can be 0.6097747727004832
Value of the floor of 2.0 is 2.0
Value of the ceiling of 2.0 is 2.0
Value of round of 2.0 is 2
The larger value between 10 and 2.0 is 10.0
The smaller value between 10 and 2.0 is 2.0