Question: *MUST BE IN JAVA* *PLEASE READ ALL DIRECTIONS BELOW AND INCLUDE STRING AND SCANNER METHODS* Write a Java class that takes a full name (first

*MUST BE IN JAVA*

*PLEASE READ ALL DIRECTIONS BELOW AND INCLUDE STRING AND SCANNER METHODS*

Write a Java class that takes a full name (first and last) as inputted by the user, and outputs the initials. Call the class Initials. The first and last names should be entered on the same input line i.e. there should be only one input to your program.

For example, if the name is Jane Doe, the initials outputted will be J and D, and the output should be as follows: J D.

Use of the java.util.Scanner class must be included in this assignment. Note: This class allows the user to provide input to your program after it has begun to run i.e. the input is not provided to the String [] argsparameter of your program's main() method, when you first invoke the java command to run it.

Hints:

1: How the Scanner class is used can be seen in the Student class, under the Java Code folder here in Blackboard.

2:The Scanner method nextLine() will return the first and last names together at once, as one string, to your Initials class.

3: The String method String substring(int beginIndex, int endIndex) will allow you to isolate the initials in the full name.

4: The String method int indexOf(String str) will return the position of the space in between the first and last names. Use the string value/literal " " as your argument to this method to find the location of the space.

5: The index of the first position in a string is 0, not 1.

You can find the String api at http://docs.oracle.com/javase/7/docs/api/java/lang/String.html for further reference.

You can find out more about the Scanner class athttp://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html .

IMPORTANT:

I would like to see good coding practises in your submission, e.g. correct naming conventions, a package name, get and set methods etc..

Create methods in your class such that all the 'computation' of figuring out the intials is not done in yourmain() method which will run your Initials class. This makes for more elegant programing, and your Initials class can be used as part of a bigger application, potentially. Use instance variables for such things and full name, first initial, last initial, the space between first and last, etc.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!