You are on page 1of 1

Exercise 5: Arrays

Objectives:

To let the participants demonstrate their skills in declaring, using and


manipulating arrays as well as methods in the String class specifically the
length and charAt methods.

To let the participants demonstrate their knowledge in accepting and


manipulating values via command line.

Create a Java program that will ask the user to input any type of String values via
command line. The output should contain the args[i] value, the length of the
inputted String, the actual String and the type of character of the last character
of the inputted String. The types of characters are as follows: vowels, consonants,
numbers and symbols. The only time you can consider a certain character as a symbol
is when it is not a vowel, nor a consonant nor a number.
Save your file as: LE5_<YourName>.java
Ie: LE5_Jose.java
Heres a sample IO:
java LE5_Jose productiveWork 7654321 javajava $$$ <ENTER>
Output:
args[0]
args[1]
args[2]
args[3]

=
=
=
=

productiveWork = 14 = consonant
7654321 = 7 = number
javajava = 8 = vowel
$$$ = 3 = symbol

Heres another sample IO:


java LE5_Jose productiveWork2 imaway seeyounextfri 0909 <ENTER>
Output:
args[0]
args[1]
args[2]
args[3]

=
=
=
=

productiveWork2 = 15 = number
imaway = 6 = consonant
seeyounextfri = 13 = vowel
0909 = 4 = number

Heres another sample IO again:


java LE5_Jose mylastexample <ENTER>
Output:
args[0] = mylastexample = 13 = vowel
You may want to study the use of the length() and the charAt() method of the String
class first before answering this lab exercise.
Assume that all inputs via command line are in small letters.

You might also like