jeudi 2 décembre 2021

Could someone tell me what is wrong with this code? [closed]

I'm recieving the 'else' without 'if' error and I don't know what to fix. Could someone tell me what is wrong with this code? Sorry that I can't embed the photo but the part that keeps giving me the error are the else's.

import java.util.Random;
 import java.util.Scanner;
class RPS
{
    public static void main (String [] args)
   {
      Scanner response = new Scanner(System.in);
      Random input = new Random();
      System.out.println("enter 0 for rock, 1 for paper, or 2 for scissors");
      int user = response.nextInt();
      int comp = input.nextInt(3);
      System.out.println("I drew: " +comp);
  
      if( user == 0 && comp == 2 ||user == 1 && comp == 0||user==2 && comp==1);
      System.out.print("you win!");
      else if(user==2 && comp ==1|| ((user == 0 && comp == 1)|| (user ==1 && comp==2)));
      System.out.println("Computer wins!");
      else if (user==2 && comp==2 || ((user == 1 && comp == 1)|| (user==0 && comp==0)));
      System.out.println("tie!");
      String user1 = response.nextLine();

Aucun commentaire:

Enregistrer un commentaire