Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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.

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."

NOTES:

(A)

Only allowed to us while, do-while, and for loops.

(B)

Given the following was entered from the keyboard:

Startingnumberoforganisms:

20

Averagedailypopulationincrease(asapercentage):

0.1

Numberofdaystheywillmultiply:

10

Output should be in this format:

... On day 3 the population size was 27. On day 4 the population size was 29. On day 5 the population size was 32. On day 6 the population size was 35. On day 7 the population size was 39. On day 8 the population size was 43. On day 9 the population size was 47. On day 10 the population size was 52.

Thank you!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions