logo Practice-It logo

halfCaps

Language/Type: Java file processing Scanner
Author: Kimberly Todd

Write a static method named halfCaps that accepts as its parameter a Scanner holding a sequence of words and outputs to the console the same sequence of words with alternating casing (lowercase, uppercase, lowercase, uppercase, etc). The first word, third word, fifth word, and all other "odd" words should be in lowercase letters, whereas the second word, fourth word, sixth word, and all other "even" words should be in uppercase letters. For example, suppose the Scanner contains the following words.

The QUick brown foX jumPED over the Sleepy student

For the purposes of this problem, we will use whitespace to separate words. You can assume that the sequence of words will not contain any numbers or punctuation and that each word will be separated by one space. For the input above, your method should produce the following output:

the QUICK brown FOX jumped OVER the SLEEPY student

Your output should separate each word by a single space. The output may end with a space if you like. Note that the Scanner may contain no words or may contain an even or odd number of words.

Type your solution here:


This is a method problem. Write a Java method as described. Do not write a complete program or class; just the method(s) above.

You must log in before you can solve this problem.


Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.