lundi 21 octobre 2019

Java use if else in Poker [on hold]

I'm very new to Java, and learning on my own. I am trying to use if else complete the exercise. I want to use if else Presenting Poker. But I don't know how to present two digit and I can't enter English letters.

How can i do?

public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
          
       System.out.println("poker:");
        
        int ch = sc.nextInt();       
        
        if (ch == 1) {
            System.out.println("Ace");                        
        }else if (ch == 2) {
            System.out.println("2");           
        }else if (ch == 3) {
            System.out.println("3");           
        }else if (ch == 4) {
            System.out.println("4");            
        }else if (ch == 5) {
            System.out.println("5");            
        }else if (ch == 6) {
            System.out.println("6");            
        }else if (ch == 7) {
            System.out.println("7");           
        }else if (ch == 8) {
            System.out.println("8");            
        }else if (ch == 9) {
            System.out.println("9");           
        }else if (ch == 10) {
            System.out.println("10");            
        }else if (ch == 10) {
            System.out.println("10");            
        }else if (ch == J) {
            System.out.println("Jack");           
        }else if (ch == Q) {
            System.out.println("Queen");
        }else if (ch == K) {
            System.out.println("King");
        }else if (ch == S) {
            System.out.println("♣");
        }else if (ch == H) {
            System.out.println("♦");           
        }else if (ch == D) {
            System.out.println("♥");
        }else if (ch == C) {
            System.out.println("♠");
        }

Image1

Image2

Aucun commentaire:

Enregistrer un commentaire