import java.util.Random; public class Ex8_1 { public static void main(String[] args) { Random rnd = new Random(); int sai, i; boolean flg = true; // 繰り返し回数が決まってない while文 i = 1; while (flg) { // flg == true である限り{ }内を繰り返す sai = rnd.nextInt(6) + 1; // 乱数[0,1,..,5] + 1 System.out.printf("\tサイコロ %d回 ... %d\n", i, sai); if (sai == 1) { // 1の目が出たら flg = false; // フラグflg を false にする } i++; } // 繰り返し回数を決まっている while文 System.out.println("カウントダウン!"); i = 5; while ( i >= 0 ) { System.out.printf("\t%d\n", i); i--; } System.out.println("ドッカーン!! ゴゴゴゴゴゴ… 無事離陸しました"); } }