# Help With Arrays/Math in Java

Now, on to the project. Remember the grain of rice story? The raja gave out 1 grain of rice on the first day and doubled every day for 30 days. Well, we are going to change the story a bit.

§ Your program will ask the user how many grains of rice they get on the first day.

o *Note: rice will double every day just like before.*

§ Your program will then ask the user for how many days they get rice.

I have two problems with this project

1) I don't know how to use exponents in Java. I believe my equation is mathematically correct but the answer is not coming out correctly

2) I dont know how to use arrays entirely so I cant print out the number of rice I Will be getting on all days.

thanks in advance

here is the equation:

java.util.Scanner;

class myown{

public static void main(String args[]){

Scanner Andrew = new Scanner(System.in);

int rice, days, answer;

System.out.println("Enter how many pieces of rice you begin with: ");

rice = Andrew.nextInt();

System.out.println("Enter how many days you will receive rice for: ");

days = Andrew.nextInt();

answer = 2rice^(days-1) ;

System.out.println(answer);

}

Your trying to overcomplicate something simple look at this code: