Question: Java homework need help ICS 211 Homework 1 Java Review Write a Java application that: - declares a Scanner variable - declares an array of
Java homework need help
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 new array, counting the number of non-vowel strings, and adding to a new result string by adding the array element to the end of the result as follows:
if the entry is a vowel ("a", "e", "i", "o", "u"), it should be added in UPPERCASE
otherwise, the entry must be added as is
- at the end of the loop, prints the result string (that has the concatenation of all the array elements, with vowels in uppercase), and the total number of non-vowel strings. In other words, the result string should have
" AbcdEfghIjklmnOpqrstUvwxyz"
Requirements
The program must catch the InputMismatchException from the call to nextInt, in which case the program must display an appropriate error message and exit the program.
The program should catch any other problems with the input, for example, a negative input number or a number larger that 25.
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).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
