4.9: 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. 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: 300.0 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: ".

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Can I get this in Java instead of C++

4.9: 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.
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: ".
Transcribed Image Text:4.9: 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. 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: ".
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education