So my java class is a joke, and we're expected to learn how to do our assignments via the web...I'm a hard worker, but I'm just not good at this.
Assignment pic
There's the assignment image. I think i got how to do the first part with the adding random numbers to the list and sorting...but I can't find other resources online that help me understand the rest. Here's my code right now
import java.util.*;
import java.io.IOException;
import java.util.Scanner;
import java.util.Random;
public class LinkedListProgram
{
public static void main(String[] args) throws IOException
{
int i,number, ran;
Scanner sc = new Scanner(System.in);
LinkedList<Integer> list = new LinkedList<Integer>();
ListIterator li;
String line;
Random random = new Random();
int pick = random.nextInt(150);
ListIterator listIterator = list.listIterator();
System.out.println("Enter # of nodes");
number = sc.nextInt();
if (number > 0)
{
for (i = 0; i < number; i++)
list.add(1+ (int)(Math.random()*150));
Collections.sort(list);
System.out.print(list + "\n");
System.out.println(listIterator.nextIndex());
}
else
System.out.println("\nnumber is less than 0\n");
}
}
Thanks for any help solving this. I'm not familiar with any of this stuff, and everything I do know is based off of what I've found via google searches. I'm nowhere near as profficient at this as you may think.