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:

  • Starting number of organisms (double):

    • must be > = 2 (do not check for non-numeric. Test only with numbers)

  • daily population increase (double)

    • must be > 0 (do not check for non-numeric. Test only with numbers)

  • number of days (integer)

    • must be >= 1 (do not check for non-numeric. Test only with numbers)

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!