Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

using loops in C++ Write a program that will predict the size of a population of

ID: 642132 • Letter: U

Question

using loops in C++

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.

Prompts, Output Labels and Messages .The three input data should be prompted for with the following prompts: "Enter the starting number of organisms: ", "Enter the average daily population increase (as a percentage): , and "Enter the number of days they will multiply: " respectively. The population sizes displayed should appear on separate lines, each of the form "On day D the population size was P." where D is the day number (starting with 1) and P is the population you calculated for that day.


Input Validation.Do not accept a number less than 2 for the starting size of the population. If the user fails to satisfy this print a line with this message "The starting number of organisms must be at least 2.", display the prompt again and try to read the value . Similarly, do not accept a negative number for average daily population increase , using the message "The average daily population increase must be a positive value ." and retrying. Finally, do not accept a number less than 1 for the number of days they will multiply and use the message "The number of days must be at least 1."

Explanation / Answer

#include #include using namespace std; int main() { float numberOfOrganisms = 0.0; int daysMultiply = 0; float dailyIncrease = 0.0; cout > numberOfOrganisms; while(numberOfOrganisms < 2) { cout numberOfOrganisms; } cout > dailyIncrease; while(dailyIncrease < 0) { cout dailyIncrease; } cout > daysMultiply; while(daysMultiply < 1) { cout daysMultiply; } for (int count = 0; count != daysMultiply; count++) { numberOfOrganisms = numberOfOrganisms + (numberOfOrganisms * dailyIncrease); cout