I was wondering if it is possible to put multiple inputs in JOptionPane.showInputDialog and then get the user input and if the user has given a wrong input for one of the questions then provide them with a error, asking them to re-enter that specific data again.
For example, in the input I want questions like;
- How many times have to been out? between 1-10.
- Do you like number 1 or 2 or 3?
- Please state for how many hours your have between 1-10 you have stop in a restaurant?
- and I will need to add some more at a later stage.
So instead of have a JOptionPane.showInputDialog for each question like this:
int timeout;
do {
String timeoutinputbyuser = JOptionPane.showInputDialog("How many times have to been out? between 1-10.");
timeout = Integer.parseInt(timeoutinputbyuser);
} while (timeout < 1 || timeout > 10);
I want to have all the questions in one and provide a suitable error if the user gets any question wrong.