Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that predicts the approximate size of a population of organisms. The application should ask the user to enter the starting number of

Write a program that predicts the approximate size of a population of organisms. The application should ask the user to enter the starting number of organisms and the number of days that the organisms will be left to multiply.

1.) Validate the input after taking it from user.

-- The number of days should be less than or equal to 20. If the user entered a wrong value for the number of days, print an error and take only the number of days, do not take the number of organisms again.

-- The starting number of organisms should be greater than equal to 2. If user entered a wrong value, print an error and take only the number of starting organisms, do not take number of days again.

-- If both of them are wrong, then take both of the input values after printing an error.

2.) Calculate the population of organisms by day using the following formula:

-- If the day number is odd, population's average daily increase will be 30%.

-- If the day number is even, population's average daily increase will be 20%.

-- Print the day number and the population (with only 2 decimal points).

For example, assume the user enters the following values, then output will look like this: Enter the number of days to grow organisms:(enter number<=20) 13

Enter the start number of organisms:(enter number>=2) 1

ERROR! The number of organisms should be >=2!

Enter the start number of organisms:(enter number>=2) 4

Day Approximate Population

------------------------------------------

1 4

2 4.80

3 6.24

4 7.49

5 9.73

6 11.68

7 15.19

8 18.22

9 23.69

10 28.43

11 36.96

12 44.35

13 57.65

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Microsoft Visual Basic 2005 For Windows Mobile Web Office And Database Applications Comprehensive

Authors: Gary B. Shelly, Thomas J. Cashman, Corinne Hoisington

1st Edition

0619254823, 978-0619254827

More Books

Students also viewed these Databases questions