1.1-Introductie-Programmeren

Adding unlimited numbers

Difficulty: Filled Filled Outlined

To practice with an ArrayList, you create a program in which the user can enter as many integers (whole numbers) as he / she wants. Of course you put all input in an ArrayList. The entry is complete as soon as a 0 is entered. Then the program will report the following:

  1. The amount of numbers entered.
  2. The last number entered.
  3. Whether the number 8 has been entered and in which position.
  4. Which number is halfway down the list and what the position of that number is.
  5. If no numbers have been entered, this must be stated. (see screenshot with the output).

See the Javadoc for the arraylist for any useful methods that you can use!

Tip

Create your program step-by-step and make sure you have a working program before going to the next step. So start with just entering numbers, then add the output one after another, but run the program each time.

Examples

Start of the program: Example

Output when numbers have been entered: Example

Output when no numbers have been entered: Example