Having trouble with this one:

The formula y = nekt can be used for estimating growth where

n is the initial amount

k is a constant

t is the time

y is the final amount

This formula will be used for estimating the bacteria growth in a lab experiment. The output should look similar to:

Enter intial bacteria amount:

5.0

Enter a constant value for k:

0.8

Time(hours) Bacteria

1 11.13

2 24.77

3 55.12

4 122.66

5 272.99

6 607.55

7 1352.13

8 3009.23

In the class Mymath , write two different methods:

a. Prompts the user initial bacteria and the constant k in the method.

b. Get the user initial bacteria and the constant k from the main method.

Write a main method to test the two methods above.

My coding:

```
import java.util.Scanner;
public class bacteriagrowth
{
public static void main(String []args)
{
Scanner input = new Scanner (System.in);
double n;
System.out.println("Enter initial bacteria amount: ");
n = input.nextDouble();
double k;
System.out.println("Enter a constant value for k: ");
k = input.nextDouble();
double t = 1;
double y = 0;
while (t<=8)
{
y = Math.pow(n*Math.E, (k*t));
t = t +1;
}
System.out.printf("time" + t, y);
}
}
```

*Edited
by peter_budo*: Please do not use Code Snipets for asking questions. Use Forum Thread option.