473,408 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Program to calculate missionaries consumed by cannibals

I'm new to C++ and I need help writing this program. If anyone can help a lot it will be real appreciated. THANKYOU!!!

Down Below..........



A single cannibal can consume 1 missionary in 30 hours. Hence he/she eats at a constant rate of 1/30 of a missionary per hour. Cannibals live in tribes with a minimum of 10 members. Missionaries travel in groups whose minimum makeup is 5. When cannibals start to feast, one cannibal each hour gets indigestion and steals away into the forest. Each cannibal eats at a constant rate. Therefore, since there are fewer consumers (cannibals), fewer missionaries will be consumed in each subsequent 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 seven miles per hour. During the darkness he reduces his speed to 4 miles per hour. Darkness lasts nine hours. Cannibals eat at 4PM sharp when there are only three hours of daylight left.



Write a program to calculate and display how many cannibals will be caught and how many missionaries saved (if any!!). Prompt the user for the number of cannibals and missionaries, keeping in mind that the minimum number of cannibals is 10 and the minimum number of missionaries is 5. Display your results in a neat orderly manner, indicating the statistics for each hour. For example, assuming you have 30 cannibals and 10 missionaries your display should look like this:



END OF MISSIONARIES LEFT CANNIBALS EATING TARZAN CURR MISS

HOUR DISTANCE BEING EATEN

----- ----------------- ---------------- -------- -----------

0 10 30 80 10

1 9 29 73 9

2 8.03333 28 66 9

. . . .

. . . .





Consider that a missionary partially consumed is not a missionary saved.
Sep 30 '07 #1
2 3568
Studlyami
464 Expert 256MB
we aren't here to do your homework, but i can recommend the first thing you do is break the problem down into smaller parts. Define the constants, define the calculations needed to be done, and define each step in those calculation. Once you have completed that attempt putting the steps into code and post problems you are having.


As for your topic title

while(MyVariable != 200) //argument that checks to see if it should run loop another time
{
MyVariable++; //will run this line of code untill MyVariable equals 200
}
Sep 30 '07 #2
sicarie
4,677 Expert Mod 4TB
As for your topic title

while(MyVariable != 200) //argument that checks to see if it should run loop another time
{
MyVariable++; //will run this line of code untill MyVariable equals 200
}
Just a note on this - this is a somewhat dangerous setup, but only because we don't see MyVariable set to anything, so if it is set to 201, this loop will never end. I would recommend

while (MyVariable < 200)

That way if it starts out illegally, you exit then as well. (And be sure you know the value of MyVariable after you leave that loop, it might not be what you think!)
Oct 1 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Ron Adam | last post by:
Hi, I'm having fun learning Python and want to say thanks to everyone here for a great programming language. Below is my first Python program (not my first program) and I'd apreciate any...
5
by: cj | last post by:
Thanks to everyone that has helped me. Now I'm trying to write my first program. I have an example of one that I need to write about. Any help getting me started is appreciated. I'm having trouble...
5
by: jbailey006 | last post by:
I am trying to add the following information to a payroll program I am working on for assignment. Modify the Payroll Program so that it uses a class to store and retrieve the employee's name, the...
1
by: cutiepie | last post by:
Hi all, I just wanted to ask you all how can i find the memory consumed by my program solution...actually i have an assignment to find different solutions and compare performance and memory...
4
nexcompac
by: nexcompac | last post by:
Ok, I posted a similar post but now need to jump back into it. Here is what I have been able to clean up. I am using textpad and jbuilder. Still getting used to the whole java world and I am...
3
by: Starbuck01 | last post by:
I have to write a program for my AP Computer Science Class. Here is the instructions. The Police Department is asking for help in catching those who speed. You will write a batch style program...
1
by: beena | last post by:
Hi All, Is there a way to calculate the maximum total memory ever used by the instance? Is db2mtrk the answer ... especially the high watermark option..... If I add up all the values......Will ...
3
by: strangetorpedo | last post by:
The problem lies under where if (choice == '2') is...I need the program to keep prompting for num and den values as long as the user enters values less than or equal to 0. Once they are values...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.