c++ assignment Rats! While in the student center finishing lunch, a gang of pira
ID: 3841282 • Letter: C
Question
c++ assignment
Rats!
While in the student center finishing lunch, a gang of pirates takes you at sword-point to their ship over by Infocision stadium and below decks and into a storage room. RATS! EVERYWHERE! Being superstitious the pirates believe that someone led the vermin on board, and as a stranger you’re the most likely suspect. You, on the other hand, as a college gra-jee-ait and know the outbreak is more likely due to the pirates’ slovenly behavior. You just have to convince them of that before they keel-haul you.
As a recipient of the finest training in C++ programming available, your best bet is writing a program to analyze the problem. You will study the epidemic by writing a program that simulates the rat population and control.
Program Details
Species rattus immaginari is subject to unusual but predictable behavior depending on such factors as carrying capacity, sanitation and the weather. The first thing to do is estimate the garbage level on a scale of 0 to 10 (0 being the IBM clean room, 10 being...well let’s not go there), decimals allowed. The carrying capacity (maximum number of rats that can be supported by the ecosystem) of an enclosed environment like a ship at sea can then be estimated as 10 times the sanitation level. Any rats in excess of this die over the space of three weeks either due to starvation or suicide (they attempt to escape the ship by swimming for it).
Important note: Live rats must contain all body parts! That means you will need to convert floating-point results to integers via type casting. For example:
int deathsFirstWeek = static_cast<int>((population–sanitation *10) / 3);
Guaranteed mortality due to the inability of the ecosystem to support the rat population aside...you have additional births and deaths, expressed as a percentage of the current total population. These rates depend on the combination of the weather and garbage level according to these parameters:
The numbers in the table are percentages. The simulation will be for three weeks.
Algorithm
1.Get the initial rat population and sanitation rating. If sanitation is negative end the program; if it’s bigger than 10 set it to 10. Provide accompanying obnoxious error messages. Validate the rat population value is numeric and a positive number greater than zero.
2.Compute carrying capacity. If the initial population is bigger than the carrying capacity, compute the excess number of rats and set deathsFirstWeek and deathsSecondWeek each to one-third of this excess, deathsThirdWeek to the remainder.
a.Otherwise initialize these three variables to zero.
3.Give the user a menu of weather conditions for the week.
4.The user should input 1, 2, or 3. If he/she doesn’t properly scold them and use option 1 (calm
weather).
5.Determine the birth and death rates as per the table above. Birth rate times total population becomes birthsFirstWeek. Similarly compute the number of additional deaths and add them to deathsFirstWeek.
a.If the total population is larger than the carrying capacity use the carrying capacity instead of total population when making these calculations.
6.The new population is the old population, plus birthsFirstWeek, minus deathsFirstWeek. If the new population is less than zero reset to zero.
If it’s larger than the carrying capacity add a third of the excess to both deathsSecondWeek and deathsThirdWeek.
7.Repeat (4) through (6) for the second week, computing birthsSecondWeek and deathsSecondWeek, plus a new total population.
8.Repeat (4) through (6) for the third week, computing birthsThirdWeek and deathsThirdWeek, plus a final total population.
9.Create a neatly formatted table with the number of births, the number of deaths and the estimated rat population remaining aboard. Be sure to label the week and include the weather description. The table header should include the sanitation level and initial population of the experiment.
10.This program must repeat (up to 10 times), taking new input for new entries of the population and sanitation rating. Therefore, after each output has been displayed your program will start again by asking for another entry. If the number of times repeated is more than 10, display a message and promptly exit. Each time before asking for new input again, the screen must scroll (roll off). You can do this in a variety of ways, however, don’t forget to pause the screen so the user can review the report prior to starting again. The option for the user to exit (no more entries) is done by using a sentinel–when sanitation is negative.
11.If the final population is more than 15% larger than the starting population suggest abandoning ship.
a.Otherwise if the final population is more than 15% smaller than the starting population, output a message urging calm on everyone’s part.
Important note: Live rats must contain all body parts! That means you will need to convert floating-point results to integers via type casting. For example:
int deathsFirstWeek = static_cast<int>((population–sanitation *10) / 3);
Sanitation Level Sanitation Level Birth Rate Death Rate 0-4 4 7 7-10 0-4 4-7 7-10 14 16 18 1 calm weather 7 6 5 1 calm weather 5 6 7 2 hot weather 2 hot weather 36 32 28 3 stormy weather 1 2 3 3 stormy weather 55 50 45Explanation / Answer
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
class weather
;
weather :: weather()
void getdata(int *m1,int *d1)
void weather :: getdetail(int d)
quantity OF RAIN: “;
cin>>rain_amt;
cout<<“ quantity OF SNOW: “;
cin >> snow_amt;
return ;
}
void weather :: putdetail()
const m=12,d=31;
main()
one. INSERT “;
cout<<“ a pair of. DISPLAY “;
cout<<“ three. EXIT “;
cout<<“ Enter your choice: “;
cin>>ch ;
switch(ch)
break;
}
}while(ch!=3);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.