Problem

Write a program that sorts and evaluates bridge hands.The input is a stream of character p...

Write a program that sorts and evaluates bridge hands.

The input is a stream of character pairs that represent playing cards. For example,

2C CD TC AD 6C 3D TD 3H 5H 7H AS JH KB

represents the 2 of clubs, queen of diamonds, 10 of clubs, acc of diamonds, and so on. Each pair consists of a rank followed by a suit, where rank is A, 2,.... 9, T, J, Q, or K, and suit is C, D, H, or S. You can assume that each input line represents exactly 13 cards and is error-free. Input is terminated by an end-of-filc.

For each line of input, form a hand of 13 cards. Display each hand in a readable form arranged both by suits and by rank within suit (aces are high). Then evaluate the hand by using the following standard bridge values:

Aces count 4

Kings count 3

Queens count 2

Jacks count 1

Voids (no cards in a suit) count 3

Singletons (one card in a suit) count 2

Doublctons (two cards in a suit) count 1

Long suits with more than 5 cards in the suit count 1

for each card over 5 iu number

For example, for the previous sample input line, the program should produce the output

because there are 2 acts, 1 king, 1 queen, 1 jack, 1 singleton, no doubletons, and no long suits. (The singleton ace of spades counts as both an ace and a singleton.)

Optional: S ee how much more flexible and fail-safe you can make your program. That is, try to remove as many of the previous assumptions in input as you can.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 2
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT