Assignment 8
Due Tuesday, October 25 at 3:20pm on Catalyst
Assignment 8.1: Playing Cards (10 pts)
- This will be one of the most challenging assignments you will do in this class, so get started early!
- Open up a new C++ file in CodeBlocks and name it cards.cpp.
- Add the necessary structure to your C++ program (block comments, iostream library, standard namespace, and a main() function)
- Make sure you have correct indentation.
- The goal of this program is to take in user input describing a playing card in the following shorthand notation:
A Ace
2....10 Card Values
J Jack
Q Queen
K King
D Diamonds
H Hearts
S Spades
C Clubs
- Your program will take in as user input a shorthand notation for a single card.
- Your program will then output the full description for that card.
- See the sample output below:
Welcome! Enter the Card Notation: QS
You Entered: Queen of Spades
- Here is another sample output:
Welcome!
Enter the Card Notation: 4H
You Entered: 4 of Hearts
- To accomplish the goals of this program, you will need to use if statements, else if statements and an else clause.
- There are two approaches to the program
- Complete
the program using 52 if statements (one for each of the possible value
and suit combinations of the playing cards). For example, your 52 if
statements will include the one below:
if (input == "QS") {
cout << "You entered: Queen of Spades\n";
} else if (input == "QH")
cout << "You entered: Queen of Hearts\n"; ...
- OR, Complete the program with fewer if statements, making use of the substr(i,n) and length() functions
- Both approaches work, and you may choose whichever option makes better sense to you.
- Important note: The tricky part will be to handle the 10 correctly.
- When you are finished, upload your cards.cpp program to Catalyst.
|
|