Introduction to Computer Science:
Assignment 30:  Evaluating Poker Hands
 Sewickley Academy, 2000-2001

See Course Home Page.
 
Date Assigned: Thu Jan-18
Date Due: Wed Jan-24

You may work in teams of 2 on this assignment (or not -- you may work alone), but you may only be on one such team.  You must not discuss this problem with anyone besides your teammate.

Write a C++ program which reads in 14 characters which represent 5 poker cards and outputs the name of the best poker hand using those 5 cards.  Each card will be two characters.  The first character will be one of A,2,3,4,5,6,7,8,9,T,J,Q,K (Ace is always low).  The second will be one of S,H,D,C (the suit -- spades, hearts, diamonds, clubs).  So "TC" is the 10 of Clubs.  Each card will be separated from the next card by a ".", so a complete hand might be:  "7H.3H.4H.6H.5H".   The poker hands you will look for, and the output you should produce, are as follows:

Straight Flush (both a Straight and a Flush -- see below for details)
    Sample Input:  7H.3H.4H.6H.5H
    Sample Output:  "Straight Flush, Hearts, 7 High"

4 of a Kind (4 of the 5 cards all have the same face value, say 4 Jacks)
    Sample Input:  JD.JS.7S.JH.JC
    Sample Output:  "4 J's"

Full House (3 of one kind, 2 of another)
    Sample Input:  KD.KH.2C.KS.2S
    Sample Output:  "Full House, K's full of 2's"

Flush (all 5 cards are in the same suit)
    Sample Input:  8D.2D.5D.QD.7D
    Sample Output:  "Flush, Diamonds, Q High"

Straight (all 5 cards are in sequence, as in A,2,3,4,5; suits do not matter; A is always low)
    Sample Input:  JD.8C.QH.TC.9S
    Sample Output:  "Straight, Q High"

Three of a Kind (3 of one kind
    Sample Input:  KD.KH.2C.QS.3S
    Sample Output:  "Trip K's"

Two Pair (2 of one kind, 2 of another)
    Sample Input:  KD.KH.2C.QS.2S
    Sample Output:  "Two Pair, K's and 2's"

One Pair (2 of one kind)
    Sample Input:  KD.JH.2C.QS.2S
    Sample Output:  "Pair of 2's"

High Card (no other hands)
    Sample Input:  KD.JH.2C.QS.3C
    Sample Output:  "K High"

Note that your program should not prompt for input, and should not output anything except precisely the output as specified above.  This will aid in partly-automated grading.

Good luck.

DK


See Course Home Page.