| .
|
LAB #3 String methods
-----------------------------
Lab #3.1: Validate String input
-----------------------------
Fix two of your earlier programs to
verify that the user has input a
valid String.
On the program that tests the user's typing
skills, verify that the input String to be
compared with "The quick brown fox jumped over
the lazy dog" is not of length zero. That is,
make sure that they entered at least one character.
If they do not enter any input, issue a message
letting the user now that no input was received.
On the Happy Birthday program, make sure
that the input name contains at least one character,
and that the name does not contain a comma (',').
-----------------------------
Lab #3.2: Concrete painter
-----------------------------
Write a program to reverse the words in a phrase.
Prompt the user for a phrase. Read the phrase
as input. Output the words in the phrase in
reverse order.
Do not use a loop.
Assume that there are exactly three words in the phrase.
Example #1
Input: Slow Children Ahead
Output: Ahead Children Slow
Example #2
Input: School Zone 15-MPH
Output: 15-MPH Zone School
-----------------------------
Challenge Lab #3.3
-----------------------------
Extend your program from Lab #3.2 above so that it
will reverse the words for a phrase of arbitrary length.
That is, the phrase can contain four words such as
Input: Merge left lane ends
Output: ends lane left Merge
HINT: The following while-loop will count from 0 to 5
num = 0;
while (num < 6) {
JJS.outputlnInt(num);
num = num + 1;
} //end while
|