I have a program that randomly flips a quarter 100 times. The results gives me a list of heads and tails. I need the results to look like this:
100 Flips resulted in 49 heads and 51 tails. With varing numbers for heads and tails.

Thank you for any help given.

I have two sets of Classes the first is FlipResult and the second is Driver. Here they are:

//FlipResult Class
import java.awt.BufferCapabilities.FlipContents;

public class FlipResult {

Quarter quarter;

public FlipResult(){

quarter = new Quarter();


public void run(){

for(int j = 0; j < 100; j++){


System.out.println(quarter.isHeads()? "heads" : "tails");




//Driver Class

public class Driver {

public static void main(String[] args) {

System.out.println("100 flips resulted in" );

FlipResult tf = new FlipResult(); 




Edited by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

6 Years
Discussion Span
Last Post by peter_budo

You may want to keep results of each flip in a collection(array, vector, list). Then ad the end you call a method to get print of how many heads and tails and forward this collection as argument for method. To get numbers, create another method that will get collection as parameter and also second parameter (heads || tails) and base on that prints position numbers where second parameter equals with entry in collection.

Try to code it, if you get in difficulties then ask

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.