Question
There is an error in the following code. if(day! = 1) on line 55 has an error in it somehow. Your help in making this
There is an error in the following code.
if(day! = 1) on line 55 has an error in it somehow.
Your help in making this compile is great.
import java.util.*;
public class Population
{
public static void main(String[] args)
{
int startingNumber;
double increasingAveragePercentage;
double numberOfMultiplyingDays;
Scanner input = new Scanner(System.in);
System.out.println("Enter the starting number"
+ " of organisms: ");
startingNumber = input.nextInt();
while(startingNumber < 2)
{
System.out.println("The starting number of"
+ " organisms should not be" + "less than 2,");
System.out.println("Enter the starting numbers"
+ " of organisms: ");
startingNumber = input.nextInt();
}
System.out.println("Enter the average daily "
+ "population increase in % ");
increasingAveragePercentage = input.nextInt();
while(increasingAveragePercentage < 0)
{
System.out.println("The average % must be"
+ " non-negative");
System.out.println("Enter the average daily "
+ "population inc in % ");
increasingAveragePercentage = input.nextInt();
}
System.out.println("Enter the number of days"
+ "they will multiply");
numberOfMultiplyingDays = input.nextDouble();
while(numberOfMultiplyingDays < 1)
{
System.out.println("The number of days should"
+ " not be less than 1.");
System.out.println("Enter the number of days"
+ "they will multiply");
numberOfMultiplyingDays = input.nextDouble();
}
System.out.printf("%-6s%20s", "Day", "Size of"
+ " Population");
System.out.println("............");
double dailyPopulation = startingNumber;
for(int day = 1; day <= numberOfMultiplyingDays; day++)
{
if(day! = 1)
{
dailyPopulation = dailyPopulation + dailyPopulation
* increasingAveragePercentage / 100.0;
System.out.printf("%-6d%20.2f",day, dailyPopulation);
System.out.println(" ");
}
}
}
}
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