ICS 211 Homework 1
Java Review
Write a Java application that:
- declares a
Scanner variable
- declares an array of 26 String values, and initializes
each array element with the corresponding lowercase letter of the alphabet
- prompts the user to enter an integer, and uses the
Scanner's nextInt method to obtain that integer from
the user
- prints out the corresponding letter from the array, so if the input is
zero, should print "a", and should print "z" for an input of 25.
- creates a new array of size 27, puts a string containing a space
(" ") at index 0 in the new array, and copies all the other
letters to positions 1..26 of the new array. The simplest way to do
this is to use System.arraycopy()
- loops through the array, printing each entry as follows:
- if the entry is a vowel ("a", "e", "i",
"o", "u"), it must be printed in uppercase
- otherwise, the entry must be printed as is
- computes and prints the number of non-vowel strings at the end of the loop.
Requirements
- The program must catch the InputMismatchException from the call
to nextInt, in which case the program must display an
appropriate error message and end the program.
- The program should catch any other problems with the input, for
example, a negative input number or a number larger that 26.
- The loop should work for any size initial array, and should not
depend on the array size -- you may use array.length to find
out the size of the array.
- You should memorize the sequence of parameters to
System.arraycopy() and their meaning. This will be useful
later in the semester (and may appear on quizzes or exams).
Turning in the Assignment
Email your assignment to the TA following the instructions posted
here.