This relates to the method userInput() and its if statements. The output for userInput() is 0 no matter what, why? I know the initial value of calculate = 0; but i want to change it so that each time the user enters "Paper" for example the value of calculate = 1; IVE TRIED EVERYTHING! now im stuck wondering whats wrong with my if statements. Please help. (sorry if i'm a noob)
import java.util.Scanner;
class RPS{
private static String[] userOption = new String[]{"Rock", "Paper","Scissors"};
public static void main(String[] args){
System.out.println("Enter: Rock, Paper Or Scissors");
System.out.println(userInput());
}
public static int userInput(){
int calculate = 99;
Scanner input = new Scanner(System.in);
String userChoice = input.nextLine();
if(userChoice == userOption[0]){
calculate = 0;
} else if(userChoice == userOption[1]){
calculate = 1;
} else if(userChoice == userOption[2]){
calculate = 2;
}
return calculate;
}
}