ava 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 don’t 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

EBK JAVA PROGRAMMING
8th Edition
ISBN:9781305480537
Author:FARRELL
Publisher:FARRELL
Chapter2: Using Data
Section: Chapter Questions
Problem 12PE
icon
Related questions
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). 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 don’t 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

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,