Suppose that you want to read an integer size, define an array names that has size locations, and read up to size names into the array. Imagine that the user types one name per line and types ## instead of a name as a signal to the program to stop reading names. After reading the names, the program should display a message that indicates why it stopped reading: Either it read ## or it read size names and could read no more.
Complete the following Java statements to accomplish these tasks:
int size = keyboard.nextInt();
// define an array called names that can hold exactly size strings
// read the strings
int index =
boolean done =
while ()
{
String input = keyboard.next();
if ()
else
} // end while
// display a message
System.out.println("Sentinel read.");
System.out.println(size + " names read.");
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here