I have been struggling to figure out how to make my code loop when asking for user input.
Basically, I want the program to re-ask the question if the user enters no text at all. This is what I done so far.
import javax.swing.JOptionPane;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Assessment {
public static void main(String[] args) throws IOException {
BufferedReader userInput = new BufferedReader(new InputStreamReader(System.in));
String me = JOptionPane.showInputDialog("Please enter your name");
System.out.println("Your name is: " + me);
String user1 = JOptionPane.showInputDialog("Please choose a number");
System.out.println("Your number is: " + user1);
String user2 = JOptionPane.showInputDialog("Please enter your choice of security, choice1(low) or choice2(high)");
String response = (String)System.in.toString();
if(user2.equals("choice1"))
JOptionPane.showMessageDialog(null,"your username is: "+me+user1,"Your username",JOptionPane.WARNING_MESSAGE);
}
}