I am new to Java, and I want to create a simple program that allows users to choose between 3 options (t,r and q). q meaning quit. I want the program to keep prompting them to choose a different option until they choose to quit. Below is my code, it doesn't work. I get the error that q,r and t need to be resolved to a variable, but when I set them as strings, it still does not work. Any help will be appreciated.
Scanner input3= new Scanner(System.in);
String choice;
boolean valid;
do
{
System.out.println("Please pick an option. t, r or q");
choice= input3.next();
if(choice==t)
{
System.out.println("You chose triangle");
valid=true;
}
else if(choice==r)
{
System.out.println("You chose rectangle");
valid=true;
}
else if (choice==q)
{
System.out.println("You chose to quit.");
valid=false;
}
else
{
System.out.println("You chose wrong.");
valid=true;
}
}
while( valid==true);