I am working on a program where I have a list of tasks each with a predicted time duration. For example: `{task: laundry, time: 1000}, {task: cooking, time: 2000}, {task: cleaning, time: 3000}`, etc. I want to pick multiple items and increment an integer variable while printing out the task to the console. My approach is to first make a HashMap with the task being the key and time being value. I then put the time values in an ArrayList and iterate through the number of times I need and increment the time variable.

The issue I run into is I need unique numbers, so I opted to use a hashset to only keep track of unique values. However, I cannot print the task with this approach and if I iterate a certain number of times, I might not get enough values in the set if the key is duplicated.

Here is my code for this part.

```
int time = 0; 
    Random rand = new Random();
    ArrayList<Integer> eta = new ArrayList<Integer>(tasks.values());
    HashSet <Integer> set = new HashSet<>();

    for (int i = 0; i<=5; i++) {
        int randomIndex = rand.nextInt(eta.size());
        int tim = eta.get(randomIndex);
        set.add(tim);
    }
    Iterator<Integer> it = set.iterator();
     while(it.hasNext()){
        System.out.println(it.next());
        time += it.next();
     }
    return time;}

```

I printed the time values to the console and got 3 values before it crashed with a `NoSuchElementException` error. Is there a way I can fix this, or is there a better approach to do this problem. It would be best if I can pick the 5 values at random and print the task and increment the time variable.

Thank You.