{ public static void main(String args[]) { Scanner sc = new Scanner(System.in);
int bat = 0; int hr = 0; try { System.out.print("Enter initial count of bacteria: "); bat = sc.nextInt();
System.out.print("Enter the number of hours: ");
hr = sc.nextInt(); }
catch (Exception ai)
{ System.out.print(ai.getMessage()); } System.out.println("The number bacteria per hour will be: "); calculate(bat, hr); } public static void calculate(int bat, int hr) { Thread threading = new Thread(); threading.start(); NumberFormat form = NumberFormat.getInstance(); form.setGroupingUsed(true); for (int n = 1; n <= bat; n++) { try { threading.sleep(2000); } catch (InterruptedException y) { System.out.println(y.getMessage()); } int x = (int)Math.pow(hr, 6); int ttl = n * x; int t = ttl / 2; int ct = t + t; System.out.println("Hour " + n + ": " + form.format(ct)); } } } Output