Need help with Rock Paper Scissors Game
Hey I'm new to the forums and to Java. I have been writing a rock, paper, scissors game and almost everything seems to be in order. But I have a line of code that contains an error I cannot catch. The compiler says "illegal start of expression when the game ends and prints the users statistics. Here's the code:
// Author:
// Started: October 14, 2008
// Finished:
//
// Game of Rock, Paper, Scissors
//
import jpb.*;
public class RPS
{
public static void main(String[ ] args)
{
// Instance variables
int wins = 0;
int losses = 0;
int draws = 0;
boolean repeat = true;
// Loop so the program can run as many times
// as the user would like
while(repeat = true)
{
SimpleIO.prompt("Rock, paper, or scissors?");
String choice = SimpleIO.readline( );
if(choice.equalsIgnoreCase("rock"))
{
System.out.println("You lose");
losses ++;
}
else if(choice.equalsIgnoreCase("paper"))
{
System.out.print("It's a draw");
draws ++;
}
else if(choice.equalsIgnoreCase("scissors"))
{
System.out.println("You win!");
wins ++;
}
else
{
System.out.println("I'm sorry, that's not an answer");
SimpleIO.prompt("Rock, paper, or scissors?");
String choice = SimpleIO.readline( );
}
// Asks the user if they want to continue
SimpleIO.prompt("Play again?");
String decision = SimpleIO.readline( );
if(decision.equalsIgnoreCase("yes"))
repeat =true;
else if (decision.equalsIgnoreCase("no"))
{
repeat = false;
// Prints the user's stats
System.out.print(wins + " wins " + losses + " losses " + );
System.out.print(draws + " draws");
}
// Displays a message depending on performance
if (wins > losses)
{
System.out.println("Good job, thanks for playing.");
}
else
{
System.out.println("It wasn't your best day.");
}
else if
{
SimpleIO.prompt("That is not an option. Play again?");
String decision = SimpleIO.readline( );
}
}
}
}
}
The error is in the two lines that print the user's stats in the middle of the program. This may seem elementary, but I am very new to Java. Thanks in advance.
reached end of file while parsing
the program is almost error free. but the IDE I am running and even DOS highlights my last curly brace and says 'reached end of file while parsing'. I tried adding and taking away curly braces and have gotten varied but unwanted results. Taking one away gives me more errors in dealing with my input statements. Adding one also gives me errors with my input statements. Any suggestions or explanations?