Q:

Java Program to Convert a Person Name in Abbreviated

0

Java program to abbreviate a given name or a java program to print short form of a name or Printing the initials of a Name or First letters of each word of a name or Write a Java Program to Convert a person's name in abbreviated or Java Program to Accept a name and print the short form of the name or Print initials of a name or how to find short form of a name in java or a java program to print short form of a name.


Explanation:- Abbreviated or sort name both are same, let's take an example and try to understand a sort name or abbreviated name, I am taking an example of my full name, My full name is " Ghanendra Pratap Singh Yadav " then my Abbreviated or Sort Name will be G. P. S. Yadav. I think now you understand the Abbreviated and sort 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 first letter of middle name(in my case that is Pratap Singh) and print 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 then sort name or Abbreviated name will be G. Yadav.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import java.util.Scanner;
import java.io.*;
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);
 }
}

 

Output:

Enter your Fisrt name: Ghanendra

Enter middle Name: Pratap

Enter your last name: Yadav

 Abbreviated Name: G.P.Yadav

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now