Work a public static method named getInitials that will take a single argument of type String...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Work a public static method named getInitials that will take a single argument of type String and will return a String. When called, and passed a name, this method must compute and return a String value with the initials for the given name. Here are some examples showing what the value returned by your getinitials method should be for different argument values: getInitials("Bob Allen Smith") should return the string value "B. A. S." getInitials("Bob Smith") should return the string value "B. S." getInitials("Bob") should return the string value "8." Note that the argument to this method may be a String containing just a first name (i.e. "Bob"), just first name and last name (i.e. "Bob Smith"), or the first name and middle name and last name (ie. "Bob Allen Smith"). You must also write a small program in the main method that will: 1. prompt the user to enter a name 2. collect and store the user's input in a String variable 3. call the getinitials method, passing the user's input as an argument 4. store the value returned by the getInitials method in another String variable 5. Display the name and initials as shown in the examples below Example 1 Enter name: Bob Allen Smith Initials for Bob Allen Smith: B. A. S. 1 // Below this comment: import the Scanner 2 3 4 public class Initials { 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 } public static void main(String[] args) { // Below this comment: declare and instantiate a Scanner // Below this comment: declare any other variables you may need // Below this comment: collect the required inputs // Below this comment: call your required method // Below this comment: disply the required results } // define your required method here below // Below this comment: import the Scanner public class Initials { public static void main(String[] args) { // Below this comment: declare and instantiate a Scanner } // Below this comment: declare any other variables you may need } // Below this comment: collect the required inputs // Below this comment: call your required method // Below this comment: disply the required results // define your required method here below Work a public static method named getInitials that will take a single argument of type String and will return a String. When called, and passed a name, this method must compute and return a String value with the initials for the given name. Here are some examples showing what the value returned by your getinitials method should be for different argument values: getInitials("Bob Allen Smith") should return the string value "B. A. S." getInitials("Bob Smith") should return the string value "B. S." getInitials("Bob") should return the string value "8." Note that the argument to this method may be a String containing just a first name (i.e. "Bob"), just first name and last name (i.e. "Bob Smith"), or the first name and middle name and last name (ie. "Bob Allen Smith"). You must also write a small program in the main method that will: 1. prompt the user to enter a name 2. collect and store the user's input in a String variable 3. call the getinitials method, passing the user's input as an argument 4. store the value returned by the getInitials method in another String variable 5. Display the name and initials as shown in the examples below Example 1 Enter name: Bob Allen Smith Initials for Bob Allen Smith: B. A. S. 1 // Below this comment: import the Scanner 2 3 4 public class Initials { 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 } public static void main(String[] args) { // Below this comment: declare and instantiate a Scanner // Below this comment: declare any other variables you may need // Below this comment: collect the required inputs // Below this comment: call your required method // Below this comment: disply the required results } // define your required method here below // Below this comment: import the Scanner public class Initials { public static void main(String[] args) { // Below this comment: declare and instantiate a Scanner } // Below this comment: declare any other variables you may need } // Below this comment: collect the required inputs // Below this comment: call your required method // Below this comment: disply the required results // define your required method here below
Expert Answer:
Answer rating: 100% (QA)
Initialsjava import javautilScanner public class Initials public static void mainString args create ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Consider purposeful organizational change through the lens of professional development for teachers. Write a 250- to 300-word response to the following: Explain why professional development...
-
The site http://virtualpiano.net features an online player piano. If you click on the Key Assist menu just above the piano keyboard, and then Keyboard Keys, you will see that each key is labelled...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
In the context of channel-of-distribution structures, discuss the distinguishing features of the Japanese distribution structure. Now, explain why the Japanese have not embraced the U.S distribution...
-
A plate-fin heat exchanger is used to condense a saturated refrigerant vapor in an air-conditioning system. The vapor has a saturation temperature of 45?C and a condensation rate of 0.015 kg/s is...
-
Why is it so important that target costing procedures focus on the customer?
-
Dr. Wayside works at a local clinic as a general practitioner. Because she has significant unsecured debt, Dr. Wayside decided to petition the United States Bankruptcy Court for relief under Chapter...
-
Company uses a standard cost system and sets predetermined overhead rates on the basis of direct labor-hours. The following data are taken from the companys budget for the current year: The standard...
-
Fluorine Limited (FL), a manufacturer of ships, has entered into the following contracts during the year ended 31 December 2022: (i) On 1 January 2022, FL entered into a contract with Alpha Limited...
-
Effective financial statement analysis requires an understanding of a firms economic characteristics. The relations between various financial statement items provide evidence of many of these...
-
Which one of the following graphs shows the correct variation of V with V? Here, V is the voltage drop across the diode and the OP-Amp is assumed to be ideal. VA (a) (c) Vo 0 V V (b) (d) V. D 74 Vo 0...
-
Most medical specialty groups historically have relied on primary care physician practices for referrals. At a recent society meeting, the senior partner returned with a renewed perspective in terms...
-
A medical group has decided to develop an industrial medicine program for employ- ers. This program would help in the treat- ment of on-the-job injuries, workers' compensation requirements, health...
-
What is the difference between an input stream and a reader?
-
Select Group has decided to offer the first accountable care plan in a small commu- nity of 25,000 people in West Virginia. Accountable care organizations (ACOS) are a new concept, especially in this...
-
Which method of sales force organization would be most appropriate for (a) a national company that sells a computer- ized billing system for small physician manufacturer of adhe- practices and (b) a...
-
Which of the following are examples of techniques used to support the Brainstorming & Definition Phase of solving a real-world ethical dilemma covered in the textbook? Identifying all stakeholders...
-
In your audit of Garza Company, you find that a physical inventory on December 31, 2012, showed merchandise with a cost of $441,000 was on hand at that date. You also discover the following items...
-
On September 14, 2012, Jay purchased a passenger automobile that is used 75 percent in his accounting business. The automobile has a basis for depreciation purposes of $35,000, and Jay uses the...
-
In the 2012 tax year, Michelle paid the following amounts relating to her 2010 tax return: Tax deficiency..........................................$5,000 Negligence...
-
Lisa Sizemore, a taxpayer in the 10-15 percent tax bracket, purchased stock as an investment on July 11, 2011. She sold the stock on July 9, 2012, 2 days before qualifying for the long-term holding...
-
Consider the situation illustrated in Figure 25. 11. A positively charged particle is lifted against the uniform electric field of a negatively charged plate. Ignoring any gravitational interactions,...
-
A positively charged particle is moved from point A to point B in the electric field of the massive, stationary, positively charged object in Figure 25. 12. (a) Is the electrostatic work done on the...
-
The negative terminal of a \(9-\mathrm{V}\) battery is connected to ground via a wire. (a) What is the potential of the negative terminal? (b) What is the potential of the positive terminal? (c) What...
Study smarter with the SolutionInn App