Counting Strings with a loop
<p>So i have written a class called Coin that includes methods that  flip a coin and recognize whether its heads or tails. It's basically a boolean that is randomly true or false, true being heads, false being tails. </p>

<p>I am now writing a class that uses methods from this Coin class. I need the methods to toss the coin, recognizes if its true or false, and then tells me if it is heads or tails. What i need this class to do is flip the coin 1 million times and tell me how many times it is heads, how many times its tails, and the percentage of flips that are heads. I'm not very experienced in loops so my main struggle is that my method in the coin class that returns heads or tails returns a string, and I dont know how to count how many times the string "heads" is returned. </p>

<p>Here is the class Coin. I realize there are many irrelevant methods in here but I have used it for other classes as well. I can't change this class either. </p>

<pre><code>import java.util.Random;

public class Coin
{
    private int m_year = 0;
    private int m_value = 0;
    private boolean m_isHeads = true;

    public Coin (int year, int value)
    {
        m_year = year;
        m_value = value;
    }

    public void toss()
    {
        Random generator = new Random();
        m_isHeads = generator.nextBoolean();
    }

    public void print()
    {
        System.out.println("Quarter Side Up = " + getSideUp());

    }

    public int getYear()
    {
        return m_year;
    }

    public int getValue()
    {
        return m_value;
    }

    public boolean isHeads()
    {
        return m_isHeads;
    }

    public String getSideUp()
    {
        if (m_isHeads)
        {
            return "Heads";
        }
        else
        {
            return "Tails";
        }
    }
}   
</code></pre>

<p>I realize this is somewhat of a broad question, but any help or suggestions would be very much appreciated. </p>
