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 ##...


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


if ()


System.out.println("Sentinel read.");


else


System.out.println(size + " names read.");



May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here