public class RockPaperScissors {
public static void main(String[] args) {
String win = "You win!";
String lose = "Sorry. You lose.";
String computerMove;
String selection;
int myMove;
int rand;
//Get myMove
TextIO.putln("What's your move?");
TextIO.putln();
TextIO.putln(" 1. Rock");
TextIO.putln(" 2. Paper");
TextIO.putln(" 3. Scissors");
myMove = TextIO.getlnInt();
//Get computerMove
rand = (int)(3*Math.random());
if ( rand == 0)
computerMove = "Rock";
else if (rand == 1)
computerMove = "Paper";
else
computerMove = "Scissors";
//Compare moves
switch (myMove) {
case 1:
selection = "Rock";
if (computerMove == "Paper")
TextIO.putln(lose);
TextIO.putln(computerMove);
TextIO.putln(" beats ");
TextIO.putln(selection);
else
TextIO.putln(win);
TextIO.putln(selection);
TextIO.putln(" beats ");
TextIO.putln(computerMove);
}
}
}
The compiler is saying the "ELSE" statement in the case labeled "Case 1" is giving me the error: "Syntax error on token "else", delete this token". What can I do to remedy this? Thanks in advance.
PS. I posted a topic earlier, but it's subject has nothing to do with the content of this one. If I've created too many topics, please feel free to let me know so I can move this into the prior topic. Thanks again.






