a JAVA program that will redict the size of a population of organisms .This prog
ID: 3546492 • Letter: A
Question
a JAVA program that will redict the size of a population of organisms .This program should ask for the starting number of organisms, their average daily population increase and the number of days they will multiply . The program should use a loop to display the size of the population for each day.
IN RECURSION PLEASE
Create a Population class:
In the main method of the population class:
- From the keyboard, enter the starting number of organisms as 21; validate the input.
- Enter the daily increase from the keyboardas 2: validate the input.
- Enter the number of days the organisms will multiple as 10; validate the input.
- Calculate and display the daily population.
- In the Population class, create a displayPopulation method that displays the population table header and then calls the recursive showPopulation method to display the daily populations.
- In the population class, create the recursive showpopulation method that displays the daily populations for a group of organisms for a specified day, and then calls itself to display the data for the remainder of the days in a time period.
- Output the following:
Enter the starting number organisms: 21
Enter the daily increase: 2
Enter the number of days the organisms will multiply: 10
Day Organisms
----------------------------------
1 (These should be double values)
2
3
(Show this through Day 10)
Explanation / Answer
import java.io.*;
import java.util.*;
import java.util.Scanner;
import java.util.Random;
public class TestProj {
public static void main(String[] a)
{
Scanner keyboard = new Scanner(System.in);
int startingSize = 0, numberOfDays = -1;
double dailyIncrease = -1;
double temp = 0;
while (startingSize < 2)
{
System.out.print("Please enter a number > 1 for the population ");
startingSize = keyboard.nextInt();
}
while (dailyIncrease < 0)
{
System.out.print("Enter a +ve no for population size increase: ");
dailyIncrease = keyboard.nextInt();
}
while (numberOfDays < 0)
{
System.out.print("Enter no of days ");
numberOfDays = keyboard.nextInt();
}
temp = startingSize;
dailyIncrease = dailyIncrease / 100;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.