Use your newfound knowledge of arrays, input and for loops to make a program that takes in text input (names) from the user, stores each one in the elements of an array and then prints out one name (randomly generated using Math.random()) of the person who has to get off the lifeboat.
so far I have
public class Int
{
public static void main(String[] args)
{
// TODO Auto-generated method stub
{
String[] names = { "mary", "sue", "jen", "sally", "pam", "jordan", "bob", "calvin", "kevin", "mike", "brendan" };
int length = names.length;
for (int i = 0; i < length; i++)
{
System.out.print(" ");
}
int rand = (int) (Math.random() * length);
System.out.print(names[rand] + " will be thrown overboard");
}
}
}
but teacher says I have to use input i.e. scanner. please help