public static void main(String[] args){

        /*The number of bacteria, B, in a culture that’s subject to refrigeration can be
approximated by this formula:
B=300000*e^-0.032t
Using this formula, write a program that prompts the user for a value of time, calculates the
number of bacteria in the culture, and displays the result. */

        Scanner i=new Scanner(System.in);
        double B,e=2.71828,t;
        Math.pow((double)e, (double)t);

        System.out.println("Please input your value of time: ");
        t=i.nextDouble();

       ** B = (300000)*Math.pow(e),(-0.032 * t);**
        System.out.println("Number of bacteria: "+B);


    }



it gives me an error
how can i make a formula multiply with that e^-0.032t?

The easiest way to get (e to the power something) is to use Math.exp(something), eg

eToThePowerFour = Math.exp(2*2);
Scanner i=new Scanner(System.in);
        double B,e=2.71828,t;
        **e=Math.exp(-0.032*t);**

        System.out.println("Please input your value of time: ");
        t=i.nextDouble();

       ** B = (300000)*e;**
        System.out.println("Number of bacteria: "+B);

Quoted Text Here

can i declare the value of e at the top so that my formula will give me this B = (300000)*e;?

Well, you can if you want. That is valid Java, but it doesn't match the formula you were given. Exponentiation comes before multiplication, so its
B=300000(e^-0.032t)
not
B=(300000
e)^-0.032t

ps You;ll get a more accurate result by using the built in value for e, which you can access as just
Math.E

ok sir thanks! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.