Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.Scanner; public class ashercards { public static void main ( String args [ ] ) { Scanner scanner = new Scanner ( System .

import java.util.Scanner;
public class ashercards
{
public static void main(String args[]){
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the card shorthand notation (e.g.3H): ");
String input = scanner.nextLine();
scanner.close();
String value = input.substring(0, input.length()-1);
char suit = input.charAt(input.length()-1);
String cardValue = getCardValue(value);
String cardSuit = getCardSuit(suit);
System.out.println("Full description of the card: "+ cardValue +" of "+ cardSuit);
}
public static String getCardValue(String value){
switch (value){
case "A": return "Ace";
case "2": return "Two";
case "3": return "Three";
case "4": return "Four";
case "5": return "Five";
case "6": return "Six";
case "7": return "Seven";
case "8": return "Eight";
case "9": return "Nine";
case "10": return "Ten";
case "J": return "Jack";
case "Q": return "Queen";
case "K": return "King";
default: return "Unknown";
}
}
public static String getCardSuit(char suit){
switch (suit){
case 'D': return "Diamonds";
case 'H': return "Hearts";
case 'S': return "Spades";
case 'C': return "Clubs";
default: return "Unknown";
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Computer Aided Database Design

Authors: Antonio Albano, Valeria De Antonellis, A. Di Leva

1st Edition

0444877355, 978-0444877352

More Books

Students also viewed these Databases questions