Examlex

Solved

Programming Write a Static Method Named LongestName That Reads Names Typed

question 3

Essay

Programming
Write a static method named longestName that reads names typed by the user and prints the longest name (the name that contains the most characters) in the format shown below. Your method should accept a console Scanner and an integer n as parameters and should then prompt for n names.
The longest name should be printed with its first letter capitalized and all subsequent letters in lowercase, regardless of the capitalization the user used when typing in the name.
If there is a tie for longest between two or more names, use the tied name that was typed earliest. Also print a message saying that there was a tie, as in the right log below. It's possible that some shorter names will tie in length, such as DANE and Erik in the left log below; but don't print a message unless the tie is between the longest names.
You may assume that n is at least 1, that each name is at least 1 character long, and that the user will type single-word names consisting of only letters. The following table shows two sample calls and their output.
Programming Write a static method named longestName that reads names typed by the user and prints the longest name (the name that contains the most characters) in the format shown below. Your method should accept a console Scanner and an integer n as parameters and should then prompt for n names. The longest name should be printed with its first letter capitalized and all subsequent letters in lowercase, regardless of the capitalization the user used when typing in the name. If there is a tie for longest between two or more names, use the tied name that was typed earliest. Also print a message saying that there was a tie, as in the right log below. It's possible that some shorter names will tie in length, such as DANE and Erik in the left log below; but don't print a message unless the tie is between the longest names. You may assume that n is at least 1, that each name is at least 1 character long, and that the user will type single-word names consisting of only letters. The following table shows two sample calls and their output.    (extra writing space for Problem #6) (extra writing space for Problem #6)


Definitions:

Employee Engagement

The degree to which employees feel passionate about their jobs, are committed to the organization, and put discretionary effort into their work.

Work Environments

The physical and social settings in which people perform their jobs, which can significantly affect their performance and well-being.

Charisma

A personal quality that gives an individual influence or authority over large numbers of people.

Goal-Based Vision

A strategy or methodology focused on establishing and achieving specific objectives or outcomes.

Related Questions