import java.util.*;
import java.lang.*;
import java.io.*;

// The main method must be in a class named "Main".
class Main {
    public static void main(String[] args) {
        // Problem4-1
        int s = (int)(Math.random()*10);
        System.out.println(s);
        for(int i=0; i<s; i++){
            System.out.print("■ ");
        }
        System.out.println("\n");

        //Problem4-2
        int j=0;
        while(j<s){
            System.out.print("■ ");
            j++;
        }
        System.out.println("\n");

        // Problem4-3
        int k=0;
        do{
            System.out.print("■ ");
            k++;
        }while(k<s);
        System.out.println("\n");

        // Problem4-4
        int a=0;
        int i=0;
        while(i<4){
            System.out.println("a=" + i);
            i++;
        }

        // Problem4-5
        int q=0;
        for(q=0; q<4; q++){
            System.out.println("a=" + q);
        }

        // Problem4-6
        int r=4;
        while(r >= 0){
            System.out.println("a=" + r);
            r--;
        }

        // Problem4-8
        while(true){
            int t = (int)(Math.random()*10) + 1;
            if(t == 10){
                break;
            }
            System.out.println(t);
        }
        System.out.println("終了します。\n");

        // Problem4-10
        for(int o=0; o<6; o++){
            int b = (int)(Math.random()*100) + 1;
            System.out.println(b);
        }
    }
}

Embed on website

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