-4

I know its probably the most brainless answer in the world, but I can't see why the else statement after the first if condition under the suited answer is not working, im just trying to get to bed soon and I want to run this at least once.

package PokerApp;
import java.util.Scanner;
public class PokerApp {

public static void main(String[] args) {

int card1 = 0;
int card2 = 0;
int play;
String fc1 = "", fc2 ="";
String answer = "";

Scanner scan = new Scanner(System.in);
System.out.println("Press 1 to evalaute your cards: ");
play = scan.nextInt();
while (play != 0){

System.out.println("First Card: ");
if (scan.hasNextInt())
{
    card1 = scan.nextInt(9)+2;
}
else{
    fc1 = scan.next();
    switch(fc1)
    {
    case "A":
        card1 = 14;
        break;
    case "K":
        card1 = 13;
        break;
    case "Q":
        card1 = 12;
        break;
    case "J":
        card1 = 11;
        break;
        default:System.out.println("Incvalid entry");
    }
}
System.out.println("Second card: ");
if (scan.hasNextInt())
{
    card2 = scan.nextInt(9) +2;
}
else{
    fc2 = scan.next();
    switch (fc2)
    {
    case "A":
        card2 = 14;
        break;
    case "K":
        card2 = 13;
        break;
    case "Q":
        card2 = 12;
        break;
    case "J":
        card2 = 11;
        break;
    default:System.out.println("Invalid entry.");
    }

}
System.out.println(card1 + "" + card2);
if(card1 == card2)
{
    System.out.println("You have a pair.");
    break;
}
//If no pair, suited engine runs conditions.
else{
    System.out.println("Are your cards suited? (y/n): ");
    answer = scan.next();
}

if (answer == "y");
{
    if(card1 == card2++ || card1++ == card2);
    {
        System.out.println("Suited connectors.");
        break;
    }

    else{
        if(card1 >= 12 && card2 >=12)
        {
            System.out.println("High value suited cards.");
            break;
        }
        else{
            if(card1 >=12 || card2 >= 12)
            {
                System.out.println("In the making for a queen high flush, or better!");
                break;
            }
            else
                System.out.println("Fold");
                break;
            }
}
//If the cards are not suited.
}

}

}
}
Linga
  • 10,379
  • 10
  • 52
  • 104
MGL94
  • 15
  • 2

1 Answers1

0

Use single quotes for compare characters, double quotes for Strings. Also remove the ; at the end of your If statement, because by adding ; you are creating an empty statement which does nothing.

if (answer == 'y') // remove ;
Linga
  • 10,379
  • 10
  • 52
  • 104