Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class countingSpaces
  3. {
  4. public static void countSpace(String Sentence)
  5. {
  6. int count = 1;
  7. for (int i = 1; i < Sentence.length(); i++)
  8. {
  9. char ch = Sentence.charAt(i);
  10. if (ch == ' ')
  11. {
  12. count++;
  13. System.out.println("Space ");
  14. }
  15. // System.out.println("There are " +count+ " Fucking words in this sentence");
  16. }
  17.  
  18.  
  19.  
  20.  
  21. }
  22.  
  23.  
  24.  
  25.  
  26. public static void main(String[] args)
  27. {
  28. {
  29. Scanner in = new Scanner(System.in);
  30.  
  31. System.out.print("Enter a Sentence, Bitch... : ");
  32. String Sentence = in.next();
  33. countSpace(Sentence);
  34.  
  35. }
  36.  
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement