Question: JAVA question: Need help with code! Need to write a method with these specifications: initArray() will ask the user for a maximum number of integers
JAVA question: Need help with code!
Need to write a method with these specifications:
initArray() will ask the user for a maximum number of integers expected, create an array of integers of that size, read at most that many integers from the keyboard using a Scanner object (ignore extra input beyond the size of the array), and return the initialized array. The user must enter a positive integer greater than 0 for the size of the array. Keep asking the user for a positive integer greater than 0 until a valid value is entered. When interacting with the user, make sure you use the given strings from PA6Strings.java to show error messages, prompts, etc.
If the user indicates EOF (see next sentence) or a non-integer input while the size is not determined yet, the program should exit with exit status 1 [System.exit(1);]. If the user hits
This is what i have so far:

Need help with cases when user enters non-integer as input when size is set and also when size is not set
Also, when i put in a value less than or equal to zero, the program terminates when its supposed to loop back and keep asking user for a valid input until one is entered
Would really appreciate the help!! Thanks so much!!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
