public class Main {
    public static void main(String[] args) {

        int p1 = (int)(Math.random() * 10) + 1;
        int p2 = (int)(Math.random() * 10) + 1;
        int p3 = (int)(Math.random() * 10) + 1;

        int d1 = (int)(Math.random() * 10) + 1;
        int d2 = (int)(Math.random() * 10) + 1;

        int player = p1 + p2;
        int dealer = d1 + d2;

        System.out.println("=== ブラックジャック ===");

        System.out.println("あなた: " + p1 + ", " + p2);
        System.out.println("合計: " + player);

        if (player <= 16) {
            System.out.println("もう1枚引きます");
            player += p3;
            System.out.println("引いたカード: " + p3);
            System.out.println("新しい合計: " + player);
        }

        while (dealer <= 16) {
            dealer += (int)(Math.random() * 10) + 1;
        }

        System.out.println();
        System.out.println("ディーラー合計: " + dealer);

        if (player > 21) {
            System.out.println("バースト!あなたの負け");
        } else if (dealer > 21) {
            System.out.println("ディーラーバースト!あなたの勝ち");
        } else if (player > dealer) {
            System.out.println("あなたの勝ち");
        } else if (player < dealer) {
            System.out.println("ざっこw");
        } else {
            System.out.println("引き分け");
        }
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: