Question
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,
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 organisms: ", "Enter the daily increase: ", and "Enter the number of days the organisms will multiply: " respectively. After the input has been read in successfully, a table is produced, for example:
----------------------------- 2 300.0 4 675.0 Under the heading is a line of 29 dashes followed by one line for each day, showing the day number and the population at the beginning of 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 "Invalid. Must be at least 2. Re-enter: " and try to read the value. Similarly, do not accept a negative number for average daily population increase, using the message "Invalid. Enter a non-negative number: " and retrying. Finally, do not accept a number less than 1 for the number of days they will multiply and use the message "Invalid. Enter 1 or more: ".
Expected output is below
Enterthestartingnumberorganisms:Enterthedailyincrease:Enterthenumberofdaystheorganismswillmultiply:DayOrganisms ----------------------------- 120.0 228.0 339.2 454.88 576.83200000000001 6107.56480000000002 7150.59072000000003 8210.82700800000003 9295.1578112000001 10413.22093568000014 11578.5093099520002 12809.9130339328003 131133.8782475059204 141587.4295465082887 152222.4013651116043 163111.361911156246 174355.906675618745 186098.269345866243 198537.57708421274 2011952.607917897836
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