06/03/2023

Convert a Person's Name in Abbreviation Program in Java

Convert a Person's Name in an Abbreviation Program in Java or a java program to print the short form of a name or Write a Program to Convert a Person's Name into an Abbreviation Program in Java or A Java Program to Accept a name and print the short form of the name or Print initials of a name or how to find a short form of a name in java or a java program to print short form of a name. Java Program to Print Short Form of a Name

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.

Convert a Person's Name in Abbreviation Program in Java

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

The Output of Abbreviation Program in Java


The Output of Abbreviation Program in Java

Similar to Java Abbreviation


Previous Post
Next Post

post written by:

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.
Follow Me

0 Comments: