/******************************************************************
 * Program: Count Spaces
 *
 * Programmer: Tyler Johnson
 *
 * Due Date: N/A

 *
 * COMP 110-001        Instructor: Tyler Johnson
 *
 * Description: This program asks the user to enter in a string and then
 *				counts the number of spaces in the string entered by the
 *				user.
 *
 * Input: A line of text (String)
 *
 * Output: The number of spaces in the string
 *
 ******************************************************************/

import java.util.Scanner;

public class CountSpaces  {

	public static void main(String[] args)  {
	
		String input;
	
		Scanner keyboard = new Scanner(System.in);
		
		System.out.println("Please enter a line of text.");
		input = keyboard.nextLine();
		
		int count = 0; //number of spaces
		int i = 0;
		int len = input.length();
		
		while(i < len)  {
			
			if(input.charAt(i) == ' ')
				count++;
				
			i++;
		}
		
		System.out.println("The number of spaces in that string is: " + count);
	
	}
}