Purpose of the Program

Using a loop structure.

Exercise

Write a program that will predict the size of a population of organisms. The program should ask for the starting number of organisms, their average daily population increase as a percentage), and the number of days they will multiply. For example, a population might begin with two organisms, have an average daily increase of 50 percent, and will be allowed to multiply for seven days. The program should use a loop to display the size of the population for each day.

Input Validation (Required): Do not accept a number less than 2 for the starting size of the population. Do not accept a negative number for average daily population increase. Do not accept a number less than 1 for the number of days they will multiply.

Notes and Comments

The file MUST be named as LastnamePass6.java (for example, my last name is Wood it will be named as woodPass6.java). Be sure to compile your program, correct any syntax errors, recompile until no errors, then test the program with different values.

Example Input and Output

Sample Run 1

Enter the starting number organisms: 48
Enter the daily increase percentage: 15
Enter the number of days the organisms will multiply: 9
Day Organisms
-----------------------------
1 48.0
2 55.2
3 63.480000000000004
4 73.00200000000001
5 83.95230000000001
6 96.545145
7 111.02691675
8 127.6809542625
9 146.833097401875

Sample Run 2 (with invalid input)

Enter the starting number organisms: -9
Invalid. Must be at least 2. Re-enter: 1
Invalid. Must be at least 2. Re-enter: 46
Enter the daily increase percentage: -7
Invalid. Enter a non-negative number: -56
Invalid. Enter a non-negative number: 6
Enter the number of days the organisms will multiply: -5
Invalid. Enter 1 or more: 0
Invalid. Enter 1 or more: -8
Invalid. Enter 1 or more: 5
Day Organisms
-----------------------------
1 46.0
2 48.76
3 51.6856
4 54.786736
5 58.07394016
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.