im trying to write a program that determines the type of hand with three cards

(one pair, three of a kind, straight, flush, straight flush, high or low card, or royal straight flush) This is my code so far. I got the cards to come up to be what they would be called, like the ace of spades, but i am having trouble to make my program determine the type. I tried to make the program to determine a flush, one pair, and three of a kind, but it doesnt work. I also cant allow the cards to be the same, like the two of hearts can't come up two or three times, but i also failed at doing that. I really need some feedback and help on this. Thank you in advance. And if anyone can help me get the straights or high or low cards to work too, i would greatly appreciate it. Im trying to work on this code this very minute and i need help

import java.util.Random;

public class java

{

public static void main(String[] args)

{

Random generating = new Random();

int x, cardSuit, cardRank, card;

String suit, rank;

for(x=1;x<=3;x++)//deal cards

{

card = generating.nextInt(52);

cardRank = card%13;

cardSuit = card/13;

if(cardSuit==1)

suit = "Hearts";

else if(cardSuit==2)

suit = "Diamonds";

else if(cardSuit==3)

suit = "Clubs";

else

suit = "Spades";

if(cardRank==0 || cardRank==13 || cardRank==26 || cardRank==39)

rank = "Ace";

else if(cardRank==1 || cardRank==14 || cardRank==27 || cardRank==40)

rank = "Two";

else if(cardRank==2 || cardRank==15 || cardRank==28 || cardRank==41)

rank = "Three";

else if(cardRank==3 || cardRank==16 || cardRank==29 || cardRank==42)

rank = "Four";

else if(cardRank==4 || cardRank==17 || cardRank==30 || cardRank==43)

rank = "Five";

else if(cardRank==5 || cardRank==18 || cardRank==31 || cardRank==44)

rank = "Six";

else if(cardRank==6 || cardRank==19 || cardRank==32 || cardRank==45)

rank = "Seven";

else if(cardRank==7 || cardRank==20 || cardRank==33 || cardRank==46)

rank = "Eight";

else if(cardRank==8 || cardRank==21 || cardRank==34 || cardRank==47)

rank = "Nine";

else if(cardRank==9 || cardRank==22 || cardRank==35 || cardRank==48)

rank = "Ten";

else if(cardRank==10 || cardRank==23 || cardRank==36 || cardRank==49)

rank = "Jack";

else if(cardRank==11 || cardRank==24 || cardRank==37 || cardRank==50)

rank = "Queen";

else

rank = "King";

if(((x==1)&&(cardSuit==0))&&((x==2)&&(cardSuit==0) )&&((x==3)&&(cardSuit==0)))//test for flush

System.out.println("Flush");

else if(((x==1)&&(cardSuit==1))&&((x==2)&&(cardSuit==1) )&&((x==3)&&(cardSuit==1)))

System.out.println("Flush");

else if(((x==1)&&(cardSuit==1))&&((x==2)&&(cardSuit==1) )&&((x==3)&&(cardSuit==1)))

System.out.println("Flush");

else if(((x==1)&&(cardSuit==1))&&((x==2)&&(cardSuit==1) )&&((x==3)&&(cardSuit==1)))

System.out.println("Flush");

if(((x==1)&&(x==2))&&((rank==rank)&&(suit!=suit)))//test for one pair

System.out.println("One pair");

if(((x==1)&&(x==2)&&(x==3))&&((rank==rank)&&(suit! =suit)))//test for three of a kind

System.out.println("Three pair");

if((x==1 && x==2)&&(rank==rank)&&(suit==suit))//cards won't be the same

card=generating.nextInt(52);

System.out.println("Card " + x + " is a " + rank + " of " + suit);

}

}

}