/**
 * Build a for loop to count
 */

public class modulus
{
    public static void main(String[ ] args)
    {
        int numb;

        System.out.println("Using the For Loop:");

        for (numb = 1; numb <= 100; numb++)      
        {
            if (numb % 2 == 0)                          //if even   
                System.out.println(numb);
        }

        System.out.println();
        System.out.println("Using the While Loop:");

        numb = 1;
        while (numb <= 100)      
        {
            if (numb % 2 == 1)                          //if odd    
                System.out.println(numb);
            numb++;
        }

        System.out.println();
        System.out.println("Counting Evens and Odds");

        int evens = 0;
        int odds  = 0;
        int rand;

        for (numb = 1; numb <= 100; numb++) 
        {
            rand = (int) (Math.random() * 100 + 1);     //random number 1 - 100       
            if (rand % 2 == 0) 
                evens++; 
            else
                odds++;
        }                   

        System.out.println("The number of even number is: " + evens);
        System.out.println("The number of odd  number is: " + odds);
    }
}