Random citizen number generator

mail@pastecode.io avatar
unknown
java
2 years ago
2.1 kB
1
Indexable
Never
package com.company;

import java.util.Random;

public class Main {

    public static void main(String arg[]) {
        System.out.println("Citizen Tracker Number for Dhaka citizen:\n");

//      class_name object_name = new class_name();
//        *             *
//        |             |
//        |             |
//      blueprint  main_stuff
        Random rn1 = new Random();

        int Dhaka;

//      counter --> 1 2 3 4 5 6 7 8 9 10 11 12 13 ... 87 88 89 90
        for (int counter = 1; counter <= 90; counter++) {

//          17 15 12 19 10

            Dhaka = 10 + rn1.nextInt(10);
            System.out.printf("%d", Dhaka);


//          24 mod 5 -- 4
//          33 mod 7 -- 5

//          44 mod 4 -- 0    | mod n  --> 0 ... n-1
//          45 mod 4 -- 1
//          46 mod 4 -- 2
//          47 mod 4 -- 3
//          48 mod 4 -- 0
//          49 mod 4 -- 1
//          50 mod 4 -- 2
//          51 mod 4 -- 3
//          52 mod 4 -- 0
//          53 mod 4 -- 1

//          counter = 5
//          counter % 5
//          counter mod 5
//          5 mod 5  --- 0
//          counter % 5 == 0
//                 0 == 0
            if (counter % 5 == 0) {
//              creates a new line
                System.out.println();
            }

        }


        System.out.println("\nTracker Number for Barisal citizen:\n");
        Random rn2 = new Random();
        int Barisal;
        for (int counter = 1; counter <= 90; counter++) {
            Barisal = 20 + rn2.nextInt(10);
            System.out.printf("%d", Barisal);
            if (counter % 5 == 0)
                System.out.println();
        }

        System.out.println("\nTracker Number for Shylet citizen:\n");
        Random rn3 = new Random();
        int Shylet;
        for (int counter = 1; counter <= 90; counter++) {
            Shylet = 30 + rn3.nextInt(10);
            System.out.printf("%d", Shylet);
            if (counter % 5 == 0)
                System.out.println();
        }


    }
}