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.
Finally, your program will build an array and print the array to show the amount of rice they get on each day.
I am trying to do this project and all I can come up with is this code
import 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 = 2^(days-1) ;
System.out.println(answer);
}
}
how am i supposed to do this with an array?
thanks in advance.


Sign In
Create Account

Back to top









