Advertisement
Guest User

Untitled

a guest
Nov 16th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. String word = "Today is good day for test. Sun is shining. The students are happy. The birds are blue.";
  2. String[] split = word.split("\\.");
  3. char ch;
  4. int counter = 0;
  5. for (int i = 0; i< word.length(); i++){
  6. ch = word.charAt(i);
  7. int asciivalue = (int)ch;
  8. if(asciivalue >=65 && asciivalue <=90){ // tuka sravnqvam vsichki bukvi ot array-a s glavnite bukvi ot ASCII tablicata
  9. counter++;
  10. }
  11.  
  12. }
  13. int maxLenght = 0;
  14. String result = " ";
  15. for (int i = 0; i <= split.length - 1; i++){
  16. if (maxLenght < split[i].length()){
  17. maxLenght = split[i].length();
  18. result = split[i];
  19. }
  20. // System.out.println(split[i]);
  21. }
  22. System.out.println(result);
  23. System.out.println(counter + " sentences in the text.");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement