Question: Java Control Structures, Arrays Write a main method that asks the user to enter 5 integers to be stored in an array (not an ArrayList).

Java Control Structures, Arrays Write a main method that asks the user to enter 5 integers to be stored in an array (not an ArrayList). If they enter something that is not an integer, you should present them with a meaningful error message and force them to try again as many times as necessary. Once they have correctly entered five integers, you should thank them and then display the integers they entered. You should write a main method but dont worry about class declarations or imports. Here is an example dialog with the user. Your output does not have to look exactly like this:

Enter an integer: 5

Enter an integer: two Not an integer. Try again.

Enter an integer: 2@ Not an integer. Try again.

Enter an integer: 2

Enter an integer: -100

Enter an integer: 0

Enter an integer: done Not an integer. Try again.

Enter an integer: 1000

Thanks. You gave me: 5 2 -100 0 1000

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!