Answer:
Written in Python
head = 0
tail = 0
for i in range(1,9):
print("Toss "+str(i)+": ")
toss = input()
if(toss == 'h'):
head = head + 1
else:
tail = tail + 1
print("Number of head: "+str(head))
print("Number of tail: "+str(tail))
print("Percent head: "+str(head * 100/8))
print("Percent tail: "+str(tail * 100/8))
Explanation:
The next two lines initialize head and tail to 0, respectively
head = 0
tail = 0
The following is an iteration for 1 to 8
<em>for i in range(1,9):
</em>
<em> print("Toss "+str(i)+": ")
</em>
<em> toss = input() </em><em>This line gets user input</em>
<em> if(toss == 'h'): </em><em>This line checks if input is h</em>
<em> head = head + 1
</em>
<em> else: </em><em>This line checks otherwise</em>
<em> tail = tail + 1
</em>
The next two lines print the number of heads and tails respectively
print("Number of head: "+str(head))
print("Number of tail: "+str(tail))
The next two lines print the percentage of heads and tails respectively
print("Percent head: "+str(head * 100/8))
print("Percent tail: "+str(tail * 100/8))