Coin Flip Grouping Results (C#) -
i having trouble assignment have, after displaying results of coin flip program, typically like: (this c# way)
heads
tails
tails
tails
etc.
i have group them in rows. example, if name group(10, 4), 10 mean total flips of "coin" , 4 how results grouped:
heads tails tails tails
tails heads tails tails
heads heads
i'm confused whether in flips() should in groups() along loop manipulate sorting of results? or totally separate? i'm stumped on how begin..
sorry, appreciated!
using system; namespace heads_tails { class mainclass { static void main() { (int v = 0; v <= 10; v++) flip (); } static void flip() { int lo, hi, n; random r = new random (); lo = 0; hi = 2; n = r.next(lo, hi); if (n == 1) { console.writeline ("heads"); } else { console.writeline ("tails"); } } } }
here's hint (since assignment):
one way pass parameters flip()
.
make instead
flip(int flipnumber, int groupby)
this way can determine within flip()
whether have start new line when print. (your value groupby
4 in example.)
Comments
Post a Comment