Answer:
// Program segment is written in Java programming language
// Comments are used for explanatory purpose
// Program segment starts here
// Initialise the two in variable to 0
count = 0;
longest =0;
// define the string variable
String myString = new String();
// Check if scanner reference contains string using while iteration
while (input.hasNext()){
// Input string while condition is true
myString = input.next();
// Compare length of string with longest variable
if (myString.length() == longest)
{
// If equal, increment count by 1
count++;
}
// If length of string is greater than longest
else
if (myString.length() > longest)
{
longest = myString.length(); // assign length of string to longest
count = 1; // set count to 1
}
}
// End of code segment