ok so what i am trying to do is create a random int and save it into an
arraylist and sum up the contents of the array list. then ask the user if they would like to roll again. any point in the right direction would be appreciated. so far this is what i have got:
import java.io.*;
import java.util.*;
public class testfp {
public static void main(String[] args)
throws FileNotFoundException {
Scanner user = new Scanner(System.in);
Random r = new Random();
System.out.println("Welcome to the exciting game of 36 ");
int roll;
int sum;
ArrayList<Integer> list = new ArrayList<Integer>();
roll = r.nextInt(6) + 1;
list.add(roll);
sum = 0;
for(int n : list){
sum += n;
}
System.out.println("You rolled a: " + roll);
System.out.println("Your sum is now: " + sum);
System.out.println("would you like to roll again? Y/N");
}
}
this is what the output is
----jGRASP exec: java testfp
Welcome to the exciting game of 36
You rolled a: 5
Your sum is now: 5
would you like to roll again? Y/N
----jGRASP: operation complete.
i do not which loop to use or where to use it