Question: Can anyone tell me how to use write this function using loop? result should be: Compartmental simulator: The compartmental simulator assumes that we are in


Can anyone tell me how to use write this function using loop?
result should be:

Compartmental simulator: The compartmental simulator assumes that we are in a closed environment (e.g., a country) with a fixed population where individuals are assigned to compartments depending on their state (e.g., infected, susceptible). We further assume that people who were infected can no longer be infected again. More specifically, we now also have: o population: the total number of persons. The number of infected persons must be equal to or smaller than the total population. o susc: the number of susceptible persons. Those are the persons who can still get infected: i.e., susc = population - inf. In practice, this reduces the number of daily infections by a factor of susc/population since only that fraction of the population that got in contact with the virus can still get infected. Note that as the number of susceptible persons goes to zero, the number of daily infections should also go to zero. Take the second sample output for an example: o If there are 100 infected persons and there are 1000 persons, only 900 persons are susceptible. Hence, if beta is 0.1, then the number of newly infected persons on the first day is 100 * 0.1 * 900 / 1000 = 9, and the total number of infected persons after that day is 100 + 9 = 109. o On the second day, the number of infected persons is 109, thus only 891 persons are susceptible now. The number of newly infected persons on the second day is 109 * 0.1 * 891 / 1000 = 10 (rounding to the nearest integer), and the new total number of infected persons is 109 + 10 = 119. //Modify two parameters in the formal parameter list. Note that you need to use "pass by reference". void CompSim(float beta, int inf, int susc, int population, int duration) Total population:1000 Input duration (days): 2 Input beta:0.1 Input number of infected persons: 100 The number of infected persons after 2 days is 119
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
