Course: Introduction to Computers & Programming (JAVA), Summer 2009
Instructor: Christopher Conway

Homework #3

Due: Tuesday, 9 June 2009 at 11:59 PM

Write a program that prompts the user to enter a sentence from the keyboard using JOptionPane.showInputDialog.

The program will print the characters back with the first letter of each word changed from lower case into upper case. If you have a capital letter in the original line and it is not the first letter of a word, then this letter should be switched from upper case to lower case. The only capital letters that should appear in the line must be the begining letter of every word in the line. All other characters will remain the same. At the end, the program will print a summary including:


Sample run:

If the user types in the following string:

This is JUst a Sample Run of the stupid homeWork.

Then the program should print out the following:

Original Sentence: This is JUst a Sample Run of the stupid homeWork.

Upper case letters : 6
Lower case letters : 33
Blank spaces : 9
Other characters : 1
Grand total : 49

Changed Sentence: This Is Just A Sample Run Of The Stupid Homework.


Extra Credit (5 points):

Extend your program so that the following words are not capitalized in the output unless they appear as the first word:
a, an, and, are, in, is, of, the
The above example would become:

This is Just a Sample Run of the Stupid Homework.

But if the input were

the extra credit is OK I guess.

the changed sentence would be

The Extra Credit is Ok I Guess.


Hint and Notes:

Style counts:

Your assignment should be submitted BY EMAIL to our class grader: Andrew Lott, adl316 (AT) nyu (DOT) edu.

Last modified: 08 Jun 2009