JAVA Write a class to manipulate a string made up of a perso

JAVA:

Write a class to manipulate a string made up of a person\'s first name, middle initial, and last name. The entire name has to be created as one field and not three separate fields. The entire name must also been created as a mixture of uppercase and lowercase letters which simply is not proper. Your goal is to output the three components of the name as separate fields with proper uppercase and lowercase letters.

Solution

public class AllName {
  
public static void main(String[] args) {
  
String input;
int space;
String fName;
String lName;
  
System.out.println();
System.out.println(\"Please enter your first name and last name, separated by a space\");
System.out.print(\"? \");
input = TextIO.getln();
  
space = input.indexOf(\' \');
fName = input.substring(0, space);
lName = input.substring(space+1);
  
System.out.println(\"Your first name is \" + fName + \", which has \"
+ fName.length() + \" characters.\");
System.out.println(\"Your last name is \" + lName + \", which has \"
+ lName.length() + \" characters.\");
System.out.println(\"Your initials are \" + fName.charAt(0) + lName.charAt(0));
  
}

}

JAVA: Write a class to manipulate a string made up of a person\'s first name, middle initial, and last name. The entire name has to be created as one field and

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site