Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 1 1. Write a method that capitalizes the first letter of each word in a sentence, named capitalizeFirstLetters. This method prints a capitalized version

image text in transcribed

Part 1 1. Write a method that capitalizes the first letter of each word in a sentence, named capitalizeFirstLetters. This method prints a capitalized version of a String to the screen -that is, it changes the first letter of each word in the string to upper case (if it is not already upper case). So "I really enjoy attending lab" becomes"I Really Enjoy Attending Lab!". The string to be printed should be a parameter to the method, and the method should have a void return. You should test your method in main by getting a line of input from the user and applying the method to it. public static void capitalizeFirstletters(String input) t //TODO: parse input for words and capitalize each one. Hint: You may want to browse the Java String docs for useful methods on strings, such as split). Hint: You can usea new Scanner to get next) words out of a String Hint: StringTokenizer is a class that can do the same thing. 2. Write a method called namelnitials that takes one String as argument, pertaining to somebody's full name and returns a String of the name's initials. Usage example, string initials nameInitials("Bertrand Arthur William Rssell): System.out.println(initials) //should print B.A.W.R 3. Write a method called letterCount that takes two String arguments, one containing some text and the other containing a single letter. This method should then compute and return the count of all of the occurrences of that letter in the given text. Usage example, int countMs; counts lettercount("I am the very model of a modern major general", "m"); System.out.println(countMs),: //should print 4

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Current Trends In Database Technology Edbt 2004 Workshops Edbt 2004 Workshops Phd Datax Pim P2panddb And Clustweb Heraklion Crete Greece March 2004 Revised Selected Papers Lncs 3268

Authors: Wolfgang Lindner ,Marco Mesiti ,Can Turker ,Yannis Tzitzikas ,Athena Vakali

2005th Edition

3540233059, 978-3540233053

More Books

Students also viewed these Databases questions