This commit is contained in:
2026-10-19 16:45:02 +09:00
parent badb7eb520
commit b6af93ba98
17 changed files with 236 additions and 15 deletions

View File

@@ -1,9 +1,61 @@
import java.util.Random;
import java.util.Scanner;
public class Question05_03 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
System.out.println(
"=========================================\n" +
"ゲームの説明\n" +
"=========================================\n" +
"これからハイ&ローゲームを行います。\n" +
"ハイ&ローゲームは、あなたのカードがディーラーのカードより大きいか小さいかを予想するゲームです。\n" +
"=========================================\n" +
"ゲーム開始\n" +
"=========================================");
Random random = new Random();
//ディーラーのカード
int dealerCard = random.nextInt(14);
System.out.println("ディーラーのカードは" + dealerCard +"です");
//自分のカード
int myCard = random.nextInt(14);
//空行
System.out.println();
System.out.println("あなたのカードがディーラのカードより大きい場合は H 小さい場合は L を入力してください。");
System.out.println("※ カードの数値が同じ場合はあなたの勝ちです。");
//あなたのカードがディーラーのカードより大きいか小さいか
Scanner scan = new Scanner(System.in);
String judgement = scan.nextLine();
System.out.println("あなたのカードは" + myCard + "です");
//空行
System.out.println();
System.out.println(
"=========================================\n" +
"勝敗判定\n" +
"========================================="
);
//勝敗判定
if((myCard == dealerCard) || (judgement == "H" && myCard > dealerCard) || (judgement == "L" && myCard < dealerCard)) {
System.out.println("あなたの勝ちです");
} else if ((judgement !="H") || (judgement != "L")) {
System.out.println("不正な値が入力されました");
} else {
System.out.println("あなたの負けです");
}
}
}

View File

@@ -1,9 +0,0 @@
public class Question05_04 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
}
}

View File

@@ -1,9 +0,0 @@
public class Question05_05 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
}
}