So this is my code so far:
import java.util.Random;
import java.util.Scanner;
class rps2{
public static void main(String args[]){
Random number = new Random();
Scanner input = new Scanner(System.in);
// player chooses
String userinput;
System.out.println("Enter your throw (rock,paper,scissors)(enter exactly as shown)");
userinput = input.nextLine();
System.out.println("The player throws "+userinput);
// computer chooses
int integer;
String computerinput;
integer = 1+number.nextInt(3);
if(integer == 1){
computerinput = "rock";
}else if(integer == 2){
computerinput = "paper";
}else{
computerinput = "scissors";
}
String message = "The computer throws "+ computerinput;
System.out.println(message);
//determining winner...
if(userinput == "rock" && computerinput == "rock"){
System.out.println("It's a tie");
}else if(userinput == "rock" && computerinput == "paper"){
System.out.println("Computer wins");
}else if(userinput == "rock" && computerinput == "scissors"){
System.out.println("You win");
}else if(userinput == "paper" && computerinput == "paper"){
System.out.println("It's a tie");
}else if(userinput == "paper" && computerinput == "rock"){
System.out.println("You win");
}else if(userinput == "paper" && computerinput == "scissors"){
System.out.println("Computer wins");
}else if(userinput == "scissors" && computerinput == "scissors"){
System.out.println("It's a tie");
}else if(userinput == "scissors" && computerinput == "rock"){
System.out.println("Computer wins");
}else if(userinput == "scissors" && computerinput == "paper"){
System.out.println("You win");
}
}
}
Everything works perfectly until it gets to the "determining winners" part. For some reason, the program just ends before it gets to the "determining winners".