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. Print out population numbers to 2-3 places after the decimal point Include the following data validation loops:
|
The program requires you to code loops.
-
Use loops for the data validation. You may use do-while or while loops. Click here for data validation code.
-
Complete the "for" loop structure to print out 1 line for each day
-
For each day, print out the population at the start and end of each day.
results should look like this
Enter starting population: -100 Invalid. Population must be 2 or greater. Enter starting population: 1 Invalid. Population must be 2 or greater. Enter starting population: 100 Enter daily growth % (.1 must be entered as 10): 10.5 Enter number of days to calculate: 10 ----------------------------------------------------------- Start Population: 100.00 Daily Percent Growth: 10.50% Number of Days: 10 Day Population Population at day start at day end ------------------------------------------------------ 1 100.00 110.50 2 110.50 122.10 3 122.10 134.92 4 134.92 149.09 5 149.09 164.74 6 164.74 182.04 7 182.04 201.16 8 201.16 222.28 9 222.28 245.62 10 245.62 271.41 |
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