Well, I'm thinking a cleaner way of going about it might be something like:
java Code:
import java.util.Scanner;public class VarnickPass6
{ public static void main
(String[] args
) { /* Constants indicating what the indices of
* populationInformation contain. */ final int NUMBER_OF_ORGANISMS
= 0; final int DAILY_INCREASE
= 1; final int NUMBER_OF_DAYS
= 2; /* Stores the user's input. */ double[] populationInformation
= new double[3]; boolean isValid
= false; //Loop condition Scanner input
= new Scanner
(System.
in); //Scanner to get user's input. while (! isValid
) { System.
out.
println("Enter the starting number of organisms:"); populationInformation
[NUMBER_OF_ORGANISMS
] = input.
nextInt(); if (populationInformation
[NUMBER_OF_ORGANISMS
] < 2) { System.
out.
println("You must enter at least 2 for the " + "starting number."); } else { isValid
= true; } } isValid
= false; while (! isValid
) { System.
out.
println("Enter the daily population increase " + "(as a percentage):"); populationInformation
[DAILY_INCREASE
] = input.
nextDouble(); if (populationInformation
[DAILY_INCREASE
] < 0) { System.
out.
println("You cannot enter a negative number for " + "daily increase."); } else { isValid
= true; } } isValid
= false; while (! isValid
) { System.
out.
println("Enter the number of days the organisms " + "will multiply:"); populationInformation
[NUMBER_OF_DAYS
] = input.
nextDouble(); if (populationInformation
[NUMBER_OF_DAYS
] < 1) { System.
out.
println("You must enter at least 1 for the " + "number of days."); } else { isValid
= true; } } }}
Let me know if there's anything else with which I can help.