Read numbers between 1 and 5, then print the minimum and maximum Just looking for some feedback regarding how to optimize my code.  It works, but just want some feedback on how to improve the solution.

Requirements:


Prompt for and read a number between 1 and 5. Repeat this step until the input is 1..5.
Repeat the following multiple times according to the number read in step 1.


a. Read in a list of integers ending with a 0. The 0 marks the end of
the input and is not considered part of the list
b. Print the largest and smallest integers in the list.
c. If only a    zero appears in the list, print an error message





CODE:

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class SIMPLE_NUMBER_PROGRAM {

    public static void main(String[] args) {

        int input = prompt();
        ArrayList&lt;Integer&gt; inputList;
        inputList = new ArrayList();
        Integer min;
        Integer max;

        if (input == 0 &amp;&amp; inputList.isEmpty()) {
            System.out.println("error: empty list!");
        } else {
            while (input &lt; 1 &amp;&amp; input != 0 || input &gt; 5 &amp;&amp; input != 0) {
                input = prompt();
            }
            while (input &gt;= 1 &amp;&amp; input &lt;= 5) {
                inputList.add(input);
                input = prompt();
            }
            min = Collections.min(inputList);
            max = Collections.max(inputList);
            System.out.println("Min: " + min + "\n" + "Max: " + max);
        }

    }

    private static int prompt() {
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter a number: ");
        return sc.nextInt();
    }

}
If you make the Scanner object outside of the prompt method and use that object in the prompt method when you want to get an input then you won't be creating a new instance of Scanner every time you call the prompt method.