dimanche 2 avril 2017

The 'ol "else without if" error

After looking at all the other questions with the same problem as me, I still cant figure out how to fix it if I remove the semi colon from the first "if" statement then it marks that as an error too and I just don't know how to fix it. Here's my code

System.out.println("Welcome to Rock, Paper, Scissors, Lizard, and Spock! This is a two player game, so make sure you have another person ready to play with you!");

System.out.println("Player 1 make your choice (R, P, X, L, S):");

char rock;
rock = "R".toLowerCase();

char paper;
paper = "P".toLowerCase(); 

char scissors;
scissors = "X".toLowerCase();

char lizard;
lizard = "L".toLowerCase();

char spock;
spock = "S".toLowerCase();

char P1 = input.nextLine();

System.out.println(" Player 2 make your choice (R, P, X, L, S):");

char P2 = input.nextLine();
{
  If(P1=='L' && P2=='P');  
 {System.out.println("Lizard Wins!");}
 else if(P2=='R')
 {System.out.println("Rock Wins!");}
 else 
 {System.out.println("Draw!");} 
}

}

}

Aucun commentaire:

Enregistrer un commentaire