This commit is contained in:
2026-10-30 15:27:20 +09:00
parent 1a12b686b1
commit f96807736e

View File

@@ -0,0 +1,35 @@
import java.util.Random;
import java.util.Scanner;
public class Q4_4 {
public static void main(String[] args) {
int map = 50;
int progress = 0;
Random random = new Random();
Scanner scanner = new Scanner(System.in);
System.out.println("===== START =====");
while (progress < map) {
System.out.print("Enterキーを押してください。さいころをふります。");
scanner.nextLine();
int dice = random.nextInt(6) + 1;
System.out.println(dice + "の目が出ました。");
progress += dice;
if (progress < map) {
int remaining = map - progress;
System.out.println("残りのマスは" + remaining + "マスです。");
}
}
System.out.println("===== GOAL =====");
scanner.close();
}
}