System.out.println("Please enter the shorthand notation of the card you want.");
String shortcard = Albert.next();
String shortvalue = shortcard.substring(0,1);
String shortsuit = shortcard.substring(1,2);
String value = "";
String suit = "";
if (shortcard.length()==2 && !shortcard.substring(0,2).equals("10") || shortcard.length()==3 && shortcard.substring(0,2).equals("10")) {
if (shortvalue.equals("A")) {value = "Ace";}
else if (shortvalue.equals("2")) {value = "Two";}
else if (shortvalue.equals("3")) {value = "Three";}
else if (shortvalue.equals("4")) {value = "Four";}
else if (shortvalue.equals("5")) {value = "Five";}
else if (shortvalue.equals("6")) {value = "Six";}
else if (shortvalue.equals("7")) {value = "Seven";}
else if (shortvalue.equals("8")) {value = "Eight";}
else if (shortvalue.equals("9")) {value = "Nine";}
else if (shortvalue.equals("J")) {value = "Jack";}
else if (shortvalue.equals("Q")) {value = "Queen";}
else if (shortvalue.equals("K")) {value = "King";}
else if (shortcard.substring(0,2).equals("10")) {value = "Ten";}
else {System.out.println("Unknown");
System.exit(0);}
if (shortsuit.equals("D")) {suit = "Diamonds";}
else if (shortsuit.equals("H")) {suit = "Hearts";}
else if (shortsuit.equals("S")) {suit = "Spades";}
else if (shortsuit.equals("C")) {suit = "Clubs";}
else if (shortcard.length()!=2 && shortcard.substring(2,3).equals("D")) {suit = "Diamonds";}
else if (shortcard.length()!=2 && shortcard.substring(2,3).equals("H")) {suit = "Hearts";}
else if (shortcard.length()!=2 && shortcard.substring(2,3).equals("S")) {suit = "Spades";}
else if (shortcard.length()!=2 && shortcard.substring(2,3).equals("C")) {suit = "Clubs";}
//I put shortcard.length()!=2 because if it is equal to 2, the computer will go to the next line without observering shortcard.substring(2,3). If it does observe that, it will print an error because there is no character at position 2
E5.19
import java.util.*;
class Uiyltrg {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
System.out.println("Please enter a value");
double x=in.nextDouble();
System.out.println("Another please");
double y=in.nextDouble();
System.out.println("Another please");
double z=in.nextDouble();
if (x>y && x>z)
{
System.out.println("The largest number is "+x);
}
if (y>x && y>z)
{
System.out.println("The largest number is "+y);
}
if (z>x && z>y)
{
System.out.println("The largest number is "+z);
}
}
}
import java.util.Scanner;
class Card {
public static void main(String[] args) {
getDescription();
}
static void getDescription() {
Scanner Albert = new Scanner(System.in);
System.out.println("Please enter the shorthand notation of the card you want.");
String shortcard = Albert.next();
String shortvalue = shortcard.substring(0,1);
String shortsuit = shortcard.substring(1,2);
String value = "";
String suit = "";
if (shortcard.length()==2 && !shortcard.substring(0,2).equals("10") || shortcard.length()==3 && shortcard.substring(0,2).equals("10")) {
if (shortvalue.equals("A")) {value = "Ace";}
else if (shortvalue.equals("2")) {value = "Two";}
else if (shortvalue.equals("3")) {value = "Three";}
else if (shortvalue.equals("4")) {value = "Four";}
else if (shortvalue.equals("5")) {value = "Five";}
else if (shortvalue.equals("6")) {value = "Six";}
else if (shortvalue.equals("7")) {value = "Seven";}
else if (shortvalue.equals("8")) {value = "Eight";}
else if (shortvalue.equals("9")) {value = "Nine";}
else if (shortvalue.equals("J")) {value = "Jack";}
else if (shortvalue.equals("Q")) {value = "Queen";}
else if (shortvalue.equals("K")) {value = "King";}
else if (shortcard.substring(0,2).equals("10")) {value = "Ten";}
else {System.out.println("Unknown");
System.exit(0);}
if (shortsuit.equals("D")) {suit = "Diamonds";}
else if (shortsuit.equals("H")) {suit = "Hearts";}
else if (shortsuit.equals("S")) {suit = "Spades";}
else if (shortsuit.equals("C")) {suit = "Clubs";}
else if (shortcard.length()!=2 && shortcard.substring(2,3).equals("D")) {suit = "Diamonds";}
else if (shortcard.length()!=2 && shortcard.substring(2,3).equals("H")) {suit = "Hearts";}
else if (shortcard.length()!=2 && shortcard.substring(2,3).equals("S")) {suit = "Spades";}
else if (shortcard.length()!=2 && shortcard.substring(2,3).equals("C")) {suit = "Clubs";}
//I put shortcard.length()!=2 because if it is equal to 2, the computer will go to the next line without observering shortcard.substring(2,3). If it does observe that, it will print an error because there is no character at position 2
else {System.out.println("Unknown");
System.exit(0);}
}
else {System.out.println("Unknown");
System.exit(0);}
System.out.print(value + " of " + suit);
}
}