Create an ArrayList of strings and call it parks. Read in the names of national parks from the user until the use
- Create an ArrayList of strings and call it parks.
- Read in the names of national parks from the user until the user enters done (or DONE,
or dOnE, .. ) Keep in mind, that the names of some national parks consist of more than one word, for example, Mesa Verde.
As you read in the national parks, add them to the list. - Next, we are going to build a string based on the elements in the list parks. Since the text keeps changing as we add one park at a time, we use class StringBuilder for this task.
- Use a StringBuilder called sb to create the string nationalParks .
- Loop through all the elements of the list parks and add them one at a time.
The resulting string should have the following format:
Favorite National Parks: {park1} | {park2} | . . . | {parkN}
The parks are separated by a space, a vertical bar, and another space. However, there is no vertical bar after the last element. {park1}, {park2}, {parkN} are the various list elements with updated spelling. - Create a private method to update the spelling.
We can't control whether the user enters the park names in uppercase or lowercase letters. However, we can change the names to a spelling where all letters are lowercase except for the first letters of each individual word. In order to make those changes, create a private method called updateSpelling. It has the following method header:
private static String updateSpelling(String text)
E.g.: When you pass the string "MESA VERDE" the method returns "Mesa Verde"
E.g.: When you pass "yEllOwstOnE" it returns "Yellowstone"
E.g.: Passing "black canyon of the gunnison" returns "Black Canyon Of The Gunnison"
E.g.: Passing "Denali" returns "Denali"
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Get ZERO PLAGIARISM, HUMAN WRITTEN ESSAYS
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.