Task:
Ten cannibals begin to eat thirty missionaries. It takes an hour to consume the first missionary. At the end of each hour, if an entire missionary has been consumed, one cannibal steals away into the forest. Each of the remaining cannibals continues to eat at the same rate. However, as there are fewer consumers, fewer missionaries will be consumed in each hour. Fortunately, for the missionaries, help is on the way. Tarzan is coming. However, he is 80 miles away. During the day, Tarzan travels at 7 miles per hour. During the darkness, he reduces his speed to 4 miles per hour. Darkness lasts nine hours. When the cannibals start eating there are only three hours left to darkness. Write a program to calculate and display how many cannibals will be caught and how many missionaries saved.
What Task Print Should look like:Display your results in the following form:
1 2 3 4 5 6 7 8 9
END OF HOUR MISSIONARIES LEFT CANNIBALS EATING TARZAN DISTANCE
0 30 10 80
1 29 9 73
2 28.1 9 66
3....
My Code:
1 2 3 4 5 6 7 8 9
x = missionaries - (canniEating*.10);
missionaries = x;
if (missionaries = 30)
canniEating = 10;
elseif (missionaries = 29 && missionaries>28)
canniEating = 9;
elseif (missionaries = 28 && missionaries > 27)
canniEating = 8;
//so on and so on till canniEating reaches 0
Problem/Question:
When this is printed I get weird numbers which means I did something wrong, but I don’t know what. How should I go about completing this part of my task? Also is there a more efficient way of doing my code? Oh and I determined the rate of consumption to be 10% per cannibal so that is why I am multiplying by .10.