I need to allow the user to input what they want into the program but restricted to the three options of, R, T and Q. I have tried to do this several times and ended up going back on myself several times. I came up with this solution but now when I run the code it simply loops round no matter what I enter into the console. Any help would be greatly appreciated, thank you.
public class Draw {
public static void main(String[] args) {
String[] options = {"R","T","Q"};
String choice;
List<String> list = Arrays.asList(options);
Scanner scanner = new Scanner (System.in);
do {
System.out.println("Press 'R' to start drawing a Rectangle.");
System.out.println("Press 'T' to start drawing a Triangle.");
System.out.println("Press 'Q' to stop.");
System.out.print("Enter one of the options: ");
choice = scanner.next();
if (options.equals("R")) {
System.out.println("You have selected to draw a Rectangle!");
System.out.println("Please enter the Height and Width of the rectangle that is within 30cm - 90cm: ");
}
else if (options.equals("T")) {
System.out.println("You have selected to draw a Tringle! Enter the three angles of the triangle between 30cm and 90cm: ");
}
else if (options.equals("Q")) {
System.out.println("Thank you for drawing with the finch, good bye.");
}
else {
System.out.println("Invalid input, try again. Enter with a capital letter one of the three options.");
}
}
while(!list.contains(choice.toLowerCase()));
}