Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: Programming: Count Words - Dialog

Write a program which counts the number of words in text the user enters.

Tutorial Details:

Write a program which counts the number of words in text the user enters. Assume that a word is any characters separated by blanks. This isn't a very good definition, but we'll use it for this program.

Don't be fooled by multiple blanks. "test this" is two words, and so is "test this". Only count blanks if the last character you saw was not a blank, or you were at the beginning.

Extra credit possiblities
Handle the case of zero length input.
After displaying an answer, go back to ask for another line.
Only count "words" that contain alphabetic characters (test with Character.isLetter()).


 

Rate Tutorial:
http://www.roseindia.net/java/java-tips/examples-introductory/dialog/q-pr-countwords.shtml

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
Programming: Count Words - Dialog

View Tutorial:
Programming: Count Words - Dialog

Related Tutorials:

Java Tip 42: Write Java apps that work with proxy-based firewalls - JavaWorld - December 1997
Java Tip 42: Write Java apps that work with proxy-based firewalls - JavaWorld - December 1997
 
Validation with Java and XML Schema, Part 2 - JavaWorld October 2000
Validation with Java and XML Schema, Part 2 - JavaWorld October 2000
 
Plant your data in a ternary search tree - JavaWorld February 2001
Plant your data in a ternary search tree - JavaWorld February 2001
 
Encapsulation is not information hiding - JavaWorld May 2001
Encapsulation is not information hiding - JavaWorld May 2001
 
Matchmaking with regular expressions - JavaWorld July 2001
Matchmaking with regular expressions - JavaWorld July 2001
 
Eclipse casts shadows
Eclipse casts shadows
 
Sort it out
Sort it out
 
Dictionary and Thesaurus API for Java
What is the Dictionary and Thesaurus API for JavaTM? The Dictionary and Thesaurus API for Java is a standard-based class library for accessing a dictionary and thesaurus using Java. It provides programming access to wordbook data from the Java programm
 
Declarative Programming in Java
Declarative Programming in Java What makes EJB components special is the declarative programming model through which we can specify the services such as security, persistence, transaction etc., that the container should provide. An EJB only implements
 
JSP 2.0: The New Deal, Part 3
JSP 2.0: The New Deal, Part 3 More Flexible JSP Document Format Rules The JSP specification supports two types of JSP pages: regular JSP pages containing any type of text or markup, and JSP Documents, which are well-formed XML documents; i.e., docum
 
FindBugs, Part 2: Writing custom detectors
FindBugs, Part 2: Writing custom detectors How to write custom detectors to find application-specific problems In the first article in this series, I showed you how to set up and execute FindBugs. Now we'll take a look at FindBugs' most powerful fea
 
NIO Tutorials
NIO Tutorials Introduction In the words of Gregory Pierce, "NIO is one of the most important but least understood APIs that came along for the ride with JDK1.4". Couldn't have put it better myself :). The aim of this series of articles is to help you
 
Tuning garbage collection in the HotSpot JVM
Packing 100 megabytes of garbage into a 50 megabyte bag.
 
Network Programming with JavaTM 2 Platform, Standard Edition 1.4 (J2SETM)
This article provides an overview of the new features and enhancements in the Java 2 Platform, Standard Edition 1.4 (J2SE), and shows you how to use them effectively.
 
Getting Started with Java Message Service (JMS)
The Java Message Service (JMS) is designed to allow Java applications to use enterprise messaging systems. It makes it easy to develop enterprise applications that asynchronously send and receive business data and events. Learn how to implement it for you
 
Running Lucene Search on WebLogic Portal 8.1
Lucene comes with two main services available: indexing and searching. The indexing tasks are done independently from the search tasks. Both the index and search services are available so that developers can extend them to meet their needs.
 
Definition of Bioinformatics
Definition of Bioinformatics Definition of Bioinformatics About Bioinformatics In February 2001, the human genome was finally deciphered! In other words, scientists have succeeded in reading the chain of more than 3 billion base pairs that
 
Buy SuSe 9.1 Personal CDs in India from us. Suse 9.1 Personal is available with us.
Buy SuSe 9.1 Personal CDs in India from us. Suse 9.1 Personal is available with us. SuSe 9.1 Personal Linux Now Available SuSe 9.1 Personal CD's SuSE 9.1 Personal Edition was based on the x86 port of the Personal Edition, and it includes all of
 
Welcome to Free search engine secrets: webmaster's guide to search engine registration!
Welcome to Free search engine secrets: webmaster's guide to search engine registration! Welcome To Webmaster's Guide T his site is dedicated to Web related services. Here you can find tools and suggestions to promote your sites to several search
 
Urchin RSS Aggregator
Urchin is a Web based, customisable, RSS aggregator and filter. It\'s primary purpose is to allow the generation of new RSS feeds by running queries against the collection of items in the Urchin database.
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.