fork download
  1. import java.util.*;
  2. import java.lang.*;
  3.  
  4. class Main
  5. {
  6. public static String findOutWhatLifeIsAllAbout() {
  7. int meaning = 0;
  8. for (int i = 0; i < 10; i++) {
  9. for (int j = 0; j < 20; j++) {
  10. for (int k = 0; k < 300; k++) {
  11. for (int m = 0; m < 7000; m++) {
  12. meaning += (int)Math.random() + 1;
  13. }
  14. }
  15. }
  16. }
  17. return String.valueOf(meaning).replaceAll("0*$", "");
  18. }
  19.  
  20. public static String findOutWhatLifeIsAllAboutAltered() {
  21. int meaning = 0;
  22. for (int i = 0; i < 10; i++) {
  23. for (int j = 0; j < 20; j++) {
  24. for (int k = 0; k < 300; k++) {
  25. for (int m = 0; m < 7000; m++) {
  26. double randomResult = Math.random();
  27. int converted = randomResult;
  28.  
  29. if (converted > 0) {
  30. System.out.println("Misbehaving double = " + randomResult);
  31. }
  32.  
  33. meaning += converted + 1;
  34. }
  35. }
  36. }
  37. }
  38. return String.valueOf(meaning).replaceAll("0*$", "");
  39. }
  40.  
  41. public static void main (String[] args) throws java.lang.Exception
  42. {
  43. System.out.println("Original: " + findOutWhatLifeIsAllAbout());
  44. System.out.println("Altered: " + findOutWhatLifeIsAllAboutAltered());
  45. }
  46. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:27: possible loss of precision
found   : double
required: int
            int converted = randomResult;
                            ^
1 error
stdout
Standard output is empty