CS2133 hw 1 #5

CS2133 hw 1 #5 - int count = 0; String str = "...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// Matt Hergenrether // CS 2133 // February 11, 2009 // Homework 1 #5 // StringTokenizer application import java.util.*; // util contains the Scanner class import java.text.*; public class sentence { public static void main(String[] args) { Scanner scan = new Scanner(System.in); // Declare variables
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: int count = 0; String str = " "; StringTokenizer st; System.out.println("Enter a sentence." ); str = scan.nextLine(); st = new StringTokenizer(str); while (st.hasMoreTokens()) { count++; } System.out.println("The sentence you entered had " + count + " words in it"); } }...
View Full Document

This note was uploaded on 09/28/2011 for the course CS 2133 taught by Professor Rao during the Fall '10 term at Oklahoma State.

Ask a homework question - tutors are online