Advertisement
Guest User

Untitled

a guest
Mar 29th, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. public class Population
  2. {
  3. public static void main(String[] args){
  4. double organism;
  5. int days;
  6. double increase;
  7. Scanner input = new Scanner(System.in);
  8. System.out.print("Enter the starting number organisms: ");
  9. organism = input.nextDouble();
  10. while(organism < 2){
  11. System.out.print("Invalid. Must be at least 2. Re-enter: ");
  12. organism = input.nextDouble();
  13. }
  14. System.out.print("Enter the daily increase: ");
  15. increase = input.nextDouble();
  16. while(increase < 0){
  17. System.out.print("Invalid. Enter a non-negative number: ");
  18. increase = input.nextDouble();
  19. }
  20. System.out.print("Enter the number of days the organisms will multiply: ");
  21. days = input.nextInt();
  22. while(days < 1){
  23. System.out.print("Invalid. Enter 1 or more: ");
  24. days = input.nextInt();
  25. }
  26. System.out.println("Day Organisms");
  27. System.out.println("-----------------------------");
  28. System.out.println("1"+ " " +organism);
  29. for( int i = 2; i <= days; i++){
  30. organism += organism*increase;
  31. System.out.println(i+" "+organism);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement