Question: Write a program that reads a 2-3 character string (which will be a shorthand notation describing a playing card) from the user and outputs the
Write a program that reads a 2-3 character string (which will be a shorthand notation describing a playing card) from the user and outputs the full description of the card.
To begin, you will get the string from the user. Input the string using a single nextLine command. The inputted string will consist of a letter or number: (A, J, Q, K, 2, 3, 4, 5, 6, 7, 8, 9, or 10) followed by another letter: (D, H, S, C)
After getting the input, your program should then print to the screen the full description of the card in the following format: VALUE of SUIT
Number cards should NOT be spelled out - just display the number; face cards, however, do need to be spelled out.
For example here are some possible input values, along with the expected output from the program:
If the user enters QS, your program should print: Queen of Spades If the user enters AH, your program should print: Ace of Hearts If the user enters 7C, your program should print: 7 of Clubs If the user enters 10D, your program should print: 10 of Diamonds If the user enters KC, your program should print: King of Clubs If the user enters JS, your program should print: Jack of Spades
The following is an example of what your MIGHT see on the screen when your program runs. The exact output depends on what values that the user types in while the program runs. Please be sure that you test ALL of the examples shown below with your program. The user's inputted values are shown below in italics:
Enter card abbreviation: KC King of Clubs
Technical Notes & Requirements:
You are NOT ALLOWED TO USE "IF" STATEMENTS in this program! You must create this program by using SWITCH statements instead.
Create a variable called result Use a SWITCH statement to assign the result variable an initial value - the value of the card Use a second SWITCH statement to concatinate to the result variable the card's suit
You may assume that the input will be correct, and therefore you don't have to worry about adding any type of error handling possibilities.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
