brilliant_moves

PopulationGrowth.java

Nov 23rd, 2015
1,315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.80 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class PopulationGrowth {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner in = new Scanner(System.in);
  7.         int initialNum, growthPeriod, hours, prediction;
  8.         double growthRate;
  9.  
  10.         System.out.print ("Enter initial number of organisms: ");
  11.         initialNum = Integer.parseInt (in.nextLine());
  12.         System.out.print ("Enter rate of growth: ");
  13.         growthRate = Double.parseDouble (in.nextLine());
  14.         System.out.println ("Enter number of hours growth period: ");
  15.         growthPeriod = Integer.parseInt (in.nextLine());
  16.         System.out.println ("Enter number of hours applied: ");
  17.         hours = Integer.parseInt (in.nextLine());
  18.    
  19.         prediction = (int) (initialNum * growthRate * hours / growthPeriod);
  20.         System.out.println("Prediction: "+prediction);
  21.     } // main()
  22.  
  23. } // class PopulationGrowth
Advertisement
Add Comment
Please, Sign In to add comment