Do you know what is wrong with my code? I want to initialize two-variable rank and suit together but I can only initialize 1. Do you know how to initialize both to be able to run the program?
Do you know what is wrong with my code? I want to initialize two-variable rank and suit together but I can only initialize 1. Do you know how to initialize both to be able to run the program?
import javax.swing.JOptionPane;
public class Lab3Q5 {
public static void main(String[] args) {
String suit;
String rank = JOptionPane.showInputDialog("Enter a Card");
if (rank.equals("A")) {
rank = "Ace";
}else if (rank.equals("2")){
rank ="Two";
}else if (rank.equals("3")){
rank ="Three";
}else if (rank.equals("4")){
rank ="Four";
}else if (rank.equals("5")){
rank ="Five";
}else if (rank.equals("6")){
rank ="Six";
}else if (rank.equals("7")){
rank ="Seven";
}else if (rank.equals("8")){
rank ="Eight";
}else if (rank.equals("9")){
rank ="Nine";
}else if (rank.equals("10")){
rank ="Ten";
}else if (rank.equals("J")){
rank ="Jack";
}else if (rank.equals("K")){
rank ="King";
}else {
rank ="Queen";
}
if (suit.equals("D")){
suit="Diamonds";
}else if(suit.equals("S")){
suit="Spades";
}else if(suit.equals("C")){
suit="Clubs";
}else {
suit="Hearts";
}
System.out.print(rank+" of "+suit);
}
}
![](/static/compass_v2/shared-icons/check-mark.png)
You have not provided the input-output format. so if you have specific input/output in mind. please repost again mentioning the format. I have assumed user input for the card as follows:
input: AD
Output: Ace of Diamond
input: 10H
Output: Ten of Hearts
input: H10
Output: Ten of Hearts
Step by step
Solved in 3 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)