oofoofoof1
03.02.2021 •
Law
What should i do if I’m a lawyer and someone pulls a in on me
Solved
Show answers
More tips
- S Style and Beauty How to Properly Tie a Tie: 5 Simple Steps...
- L Leisure and Entertainment How to Make a Crab Trap in Just a Few Minutes...
- H Health and Medicine How Much Does Abortion Cost? Expert Answers and Insights...
- S Sport How to Build Arm Muscles? Effective Exercises and Tips...
- H Health and Medicine When can it be said that a person has a normal pulse?...
- A Art and Culture When Will Eurovision 2011 Take Place?...
- S Style and Beauty How to Choose the Perfect Hair Straightener?...
- F Family and Home Why Having Pets at Home is Good for Your Health...
- H Health and Medicine How to perform artificial respiration?...
- H Health and Medicine 10 Tips for Avoiding Vitamin Deficiency...
Answers on questions: Law
- L Law What is a federal and a unitary constitution?...
- H History ? What was the intent of the Roosevelt Corollary? to make peace between California s school system and Japan to enforce Cuba s freedom from Spanish domination to negotiate...
- B Biology Please can anyone help me out in this whole definition actually I can t understand it...
Ответ:
i think you forgot something lol
have a nice day! (^o^)
Ответ:
The code is given below in Java with appropriate comments
Explanation:
//declaring the imports
import java.util.Scanner;
//class FormatName
public class FormatName {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
//inputing the names
System.out.print("Enter your name (first middle last): ");
String fullName = scanner.nextLine();
String[] names = fullName.split("\\s+");
//applying the formatting
if (names.length == 2) {
System.out.println("Formatted Name: " + names[1] + ", " + names[0]);
} else if (names.length == 3) {
System.out.println("Formatted Name: " + names[2] + ", " + names[0] + " " + names[1].charAt(0) + ".");
} else {
System.out.println("The input does not have correct form");
}
}
}