Question
17. Population Write a program that will predict the size of a population of organisms. The program should ask the user for the starting number
17. 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 of current population), and the number of days they will multiply. A loop should display the size of the population for each day. Input Validation: The program should not accept a number less than 2 for the starting size of the population, a negative number for average daily population increase, or a number less than 1 for the number of days they will multiply. In addition to the book specs, include the following data validation loops: Starting number of organisms - must be numeric and >= 2. daily population increase - must be > 0 (do not check for non-numeric) number of days - must be >= 1 (do not check for non-numeric) |
The program requires you to code loops.
Use loops for the data validation. You may use do-while or while loops. (These links take you to other parts of the current document)
Complete the "for" loop structure to print out 1 line for each day with start and end population
Population should not be displayed with values after the decimal point. It should be displayed as an integer.
Print out population at the start and end of each day.
Refer to the Programming Standards document and follow the rules stated there in order
#include#include using namespace std; //container for preprocessor directives int main() { int growth, days, count; int population = 0, startPop; cout > startPop; /* Code the data validation loop to ensure that startPop is a number greater than 2 */ do { cout > growth; }while (growth > days; while (days > days; } cout Chrome File Edit View History Bookmarks People Window Help 865% -), Sat 3:50 PM a / e Chegg Study Gu G 17. Population w Population Progr x eChegg Study Gu Week 5-182CIS lab2 ncomplete x c secure https://docs.google.com/document/d/1mHIh-2uFlatQf1UmdTKUNmyNeoW7mMO65D40Z-Si82c/edit# weeks_ab2 spec x s, isai Apps https://worshipartist http://alt torrent.com 1 1 https://consumerce.. https:// stitorr ent.co... http://mac-torrent-d https://www.chegg.c http://www.misterse. Search the menus (Option 100% O View only Rename the document as per the Programming Standards document Make the following changes to the program: . Outline In lines 14-17, code a data validation loop that detects and recovers from non-numeric input and numeric input that is less than 2. Code to do so is shown later on in this document In lines 55-58, code statements in the loop to displays each day's starting and ending population. Hint: Day2's starting population is Day1's ending population o Contents o Introduction Refer to the ument and follow the rules stated there in order to complete the program. lab2 incomplete.cpp Tasks to be completed Sample output from my implementati Sample output from my implementation of the Lab User input is shown in bold blue lettering highlighted in yellow: Enter starting population: kljf Invalid. Input must be numeric Enter starting population: -108 Invalid. Population nust be 2 or greater Enter starting population: 1 Invalid. Population nust be 2 or greater Enter starting population: 123 Enter daily growth % ("I must be entered as 18. No decimals!): 12 Enter number of days to calculate: 6 Submit Instructions Code that clears buffer, checks for no... Data validation using while loop Start Population: 123 Daily Percent Growth: 12% Number of Days: 6 Data validation using do-while loop Day Population Population at day end at day start 123 137 Page 3 of 6 El Ciclo y la+Tierrra-.. zip Show All
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started