Abbreviated or sort names both are the same, let's take an example and try to understand a sort name or abbreviated name, I am taking the example of my full name, My full name is " Ghanendra Pratap Singh Yadav " then my Abbreviated Sort Name will be G. P. S. Yadav. I think now you understand the Abbreviated and sorted name now comes to the problem.
So for sort name and Abbreviated name as you can see above we have to print the first letter of your first name(in my case that is Ghanendra), and the first letter of your middle name(in my case that is Pratap Singh) and print the the the the full last name(that is Yadav in my case).
Note: Most people don't have a middle name so for them print the only first letter of the first name and last name Ie. The name is Ghanendra Yadav the sort name or Abbreviated name will be G. Yadav. Below is the Java program to print the initials of names and surnames.
Read: C++ Program to Convert a person's name in abbreviated
Convert a Person's Name in Abbreviation Program in Java
import java.util.Scanner;
import java.io.*;
/* Java Program to Convert a Person Name in Abbreviated */
class abbreviated {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("\nEnter your Fisrt name:\t");
char firstname = br.readLine().charAt(0);
System.out.print("\nEnter middle Name:\t");
char midname = br.readLine().charAt(0);
System.out.print("\nEnter your last name:\t");
String lastname = br.readLine();
System.out.println("\n Abbreviated Name:\t" + firstname + "." + midname + "." + lastname);
}
}
Read: C Program to Convert a person's name in abbreviated
0 Comments: