i have been working on this code that tells that gives a random number and interprets it as a heads or tail on a coin and therefore predicts the probability of a 50/50 chance. the only problem is that i need to add something to the code to where it will automatically tell me how many heads and how many tells it returns. thank you in advance for any help.
You can use a variable for example headCount and increment it every time a head is flipped. With this and the flip count you know the number of heads and tails.
i think i get what you are saying, but my problem is that i really dont know how to translate that into code that will work with my program. im a beginner, sorry.
it still isnt quite working correctly. im sure it is my own fault for making this more difficult than it is, but the program is supposed to ask me for the number of flips, it is supposed to output something like this,
Program Output
Just think about what you want. You wolud like to write out whether a tail or a head is flipped and you wolud like to write out the random number for every flip. But what about the number of tails and number of heads? Do you really want to print them out after every flip? I don't think so. So the only thing to do is to put the code which prints the number of heads and tails to the end of the program.
Don't get me started about those stupid light bulbs.