OK yes I’m an idiot…
Here’s the part of the code I’m having trouble with:
for ($cointoss = rand(1,2); $toss = $toss;) {
if ($cointoss = 1) {
$heads = 1;
print "Number of heads, $heads
";
}
else {
$tails = 2;
print "Number of tails, $tails
";
}
}
//end of my crapy code...
I’ve already set the $toss in the form. It’s giving me an infinite loop or whatever. What I’m tryin to do is have the user type in the number of tosses they want it to do (which is going to be defined as $toss) and then have it count how many heads and tails in total and out put it back to the user. Like “Number of heads, 10” “Number of tails, 10” “You flipped the coin 20 times”. That kinda thing.
Please don’t give me the answer straight up, it’s for class I don’t want to cheat. What I want is some help as to what the hell I’m doing wrong. The teacher tried explaining it to me, but I didn’t get it and I REALLY had to be somewhere so I didn’t ask for a clarification. PLEASE someone help me!!!!!!
2007-02-26
07:35:30
·
5 answers
·
asked by
Am
4