Project 1 - A Card Comparison Program

Part 1 - Due - March 1, 2004

Part 2 - Due - March 8/9, 2004

In this project, you will write a program that compares two playing cards and determines which card has a higher value. Your program should prompt the user for values for the two cards, convert the characters entered into numerical values, and compare the values. A card is represented by two characters, a rank and a suit. For example, 2H would represent the two of hearts and AS would represent the Ace of spades. Values for the rank are as follows:
A - 1
2 - 2
3 - 3
4 - 4
5 - 5
6 - 6
7 - 7
8 - 8
9 - 9
T - 10
J - 11
Q - 12
K - 13

Values for the suit are as follows:
H - 1
S - 2
C - 3
D - 4

If card 1 has a higher suit than card 2, it has a higher value (i.e, 2D is higher than KH). If two cards have the same suit, the card with the higher rank has a higher value. Your program should ask the user to enter two characters representing Card 1. Read in the two chars and convert each character to its respective value. You should have a function that takes as input a rank character and returns a rank value (integer) and a function that takes as input a suit character and returns a suit value (integer). Next, ask the user to do the same for Card 2 and perform the same conversion.

Once you have the values for each card, you need to compare them. You should have at least one function to compare the suits and ranks of the cards. Depending on your design, you may have more than one function to perform the comparison. Once you determine which card is greater, print a message for the user that indicates the winner. For example, you might print Card 1 is greater than Card 2.

Part 1 - Due Monday, March 1, 2004

Think about your algorithm, code design, and test cases. Write down your algorithm and the design of your code. Your design should include documentation for all functions you will use in your program. The documentation should include the input, output, and side effects of each function.
  1. Turn in your algorithm, design document, and set of test cases.

Part 2 - Due Monday, March 8, 2004

  1. Complete your code.
  2. Make sure that each function is well documented. Your documentation should specify the type and function of the input paramaters and ouput.
  3. Make sure a lab assistant (Dianne or I) has seen your program run.
  4. Copy and paste the output of your program to the bottom of your program itself. Make sure the output is a comment. That means, put a /* before the output and a */ after the output.

Sami Rollins