Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class NameFormat {
- public static void main(String[] args){
- Scanner scnr = new Scanner(System.in);
- String firstName, middleName, lastName;
- firstName = scnr.next();
- middleName = scnr.next();
- lastName = scnr.nextLine();
- if (lastName.equals("")){
- System.out.println(middleName + ", " + firstName.charAt(0) + ".");
- } else {
- lastName = lastName.substring(1);
- System.out.println(lastName + ", " + firstName.charAt(0) + "." + middleName.charAt(0) + ".");
- }
- scnr.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment