5.11: Population Write a program that will predict the size of a population of organisms. The program should ask the user for the starting number of organisms, their average daily population increase (as a percentage, expressed as a fraction in decimal form: for example 0.052 would mean a 5.2% increase each day), and the number of days they will multiply. A loop should display the size of the population for each day.
1 answer
Question:
5.11: Population Write a program that will predict the size of a population of organisms. The program should ask the user for the starting number of organisms, their average daily population increase (as a percentage, expressed as a fraction in decimal form: for example 0.052 would mean a 5.2% increase each day), and the number of days they will multiply. A loop should display the size of the population for each day.
Answer:// using c++ language#include "stdafx.h";
#include <iostream>
#include<cmath>
using namespace std;
//startint main()
{
//Declaration of variables in the program double start_organisms;
double daily_increase;
int days;
double updated_organisms;
//The user enters the number of organisms as desired cout << "Enter the starting number of organisms: ";
cin >> start_organisms;
//Validating input data while (start_organisms < 2)
{
cout << "The starting number of organisms must be at least 2.\n";
cout << "Enter the starting number of organisms: ";
cin >> start_organisms;
}
//The user enters daily input, here's where we apply the 5.2% given in question cout << "Enter the daily population increase: ";
cin>> daily_increase;
//Validating the increase while (daily_increase < 0)
{
cout << "The average daily population increase must be a positive value.\n ";
cout << "Enter the daily population increase: ";
cin >> daily_increase;
}
//The user enters number of days cout << "Enter the number of days: ";
cin >> days;
//Validating the number of days while (days<1)
{
cout << "The number of days must be at least 1.\n";
cout << "Enter the number of days: ";
cin >> days;
}
//Final calculation and display of results based on formulas for (int i = 0; i < days; i++)
{
updated_organisms = start_organisms + (daily_increase*start_organisms);
cout << "On day " << i + 1 << " the population size was " << round(updated_organisms)<<"."<<"\n";
start_organisms = updated_organisms;
}
system("pause");
return 0;
//end}
A young boy constantly tricks the people in his town into believing a wolf is attacking him and his flock of sheep. When a wolf actually attacks the boy, the townspeople don't believe him and refuse to help. The boy learns a valuable lesson about the dangers of lying.
What literary form is this stor...
¡Ahora, hazlo tú!1.Construye en tu cuaderno una circunferencia de:a.2 cm de radio y halla su longitud.b. 3 cm de radio y halla su longitud.C.4 cm de radio y halla su longitud.d.10 cm de diámetro y halla su longitud.e.12 cm de diámetro y halla su longitud....
I need someone to explain to me this in steps how to solve this, please help.
The price of a dozen cookies at a bake sale last year was $2. This year, the price for a dozen cookies was $5. What is the percent of change?...
Order the various instruments used for measuring water in this experiment (balances, graduated cylinders, beaker and pipette) from the most accurate to the least accurate, Use sentence(s)....
Read the speech excerpt to answer the question that follows.
"Yesterday, December 7, 1941—a date which will live in infamy—the United States of America was suddenly and deliberately attacked by naval and air forces of the Empire of Japan. … I regret to tell you that very many American lives ha...