fork download
  1. package readability;
  2. import java.io.*;
  3. import java.util.*;
  4. import java.util.Scanner;
  5.  
  6. public class Main {
  7. public static void main(String[] args) {
  8. String data = "";
  9. try {
  10. File myObj = new File("input.txt", "in.txt");
  11. Scanner myReader = new Scanner(myObj);
  12. System.out.println("Java Main " + myObj.getName());
  13. System.out.println("The text is :");
  14. while (myReader.hasNextLine()) {
  15. data = myReader.nextLine();
  16. System.out.println(data);
  17. }
  18. myReader.close();
  19. } catch (FileNotFoundException e) {
  20. System.out.println("An error occurred.");
  21. }
  22.  
  23. System.out.println();
  24.  
  25. int countWords = data.split(" ").length;
  26. System.out.println("Words: " + countWords);
  27.  
  28. int countSc = data.split("[!?.:]+").length;
  29. System.out.println("Sentences: " + countSc);
  30.  
  31. int countCh = data.replace(" ", "").length();
  32. System.out.println("Characters: " + countCh);
  33.  
  34. double score = 4.71 * countCh/countWords + 0.5 * countWords/countSc - 21.43;
  35. double d = (Double)Math.floor(score*100)/100.0;
  36. System.out.println("The score is: " + d);
  37. int ab = (int)Math.ceil(d);
  38.  
  39. String age = "";
  40. switch (ab) {
  41. case 1:
  42. age = "5-6";
  43. break;
  44. case 2:
  45. age = "6-7";
  46. break;
  47. case 3:
  48. age = "7-9";
  49. break;
  50. case 4:
  51. age = "9-10";
  52. break;
  53. case 5:
  54. age = "10-11";
  55. break;
  56. case 6:
  57. age = "11-12";
  58. break;
  59. case 7:
  60. age = "12-13";
  61. break;
  62. case 8:
  63. age = "13-14";
  64. break;
  65. case 9:
  66. age = "14-15";
  67. break;
  68. case 10:
  69. age = "15-16";
  70. break;
  71. case 11:
  72. age = "16-17";
  73. break;
  74. case 12:
  75. age = "17-18";
  76. break;
  77. case 13:
  78. age = "18-24";
  79. break;
  80. case 14:
  81. age = "24+";
  82. default:
  83. age = "no argument passed";
  84.  
  85. }
  86.  
  87. System.out.println("This text should be understood by " + age + " year olds.");
  88.  
  89. }
  90. }
  91.  
Runtime error #stdin #stdout #stderr 0.07s 33848KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: readability/Main (wrong name: Main)