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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started