Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class countingSpaces
- {
- public static void countSpace(String Sentence)
- {
- int count = 1;
- for (int i = 1; i < Sentence.length(); i++)
- {
- char ch = Sentence.charAt(i);
- if (ch == ' ')
- {
- count++;
- System.out.println("Space ");
- }
- // System.out.println("There are " +count+ " Fucking words in this sentence");
- }
- }
- public static void main(String[] args)
- {
- {
- Scanner in = new Scanner(System.in);
- System.out.print("Enter a Sentence, Bitch... : ");
- String Sentence = in.next();
- countSpace(Sentence);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement