Go to Top

Monday, 3 October 2011

Utilities 12 : Name initials

This program will help you to print the initials of a name taken as input from the user.

Java Program :

import java.io.*;
class name_initials
{
 static void main()throws IOException
 {
     BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
     int i,d=0,space=0;
     char k;
     String a;
     System.out.print("Enter the name : ");
     a=br.readLine();
     System.out.print("\nName initials : ");
     for(i=0;i<a.length();i++)
     {
         k=a.charAt(i);
         if(k==' ')
         {
             space=i+1;
             System.out.print(a.charAt(d)+".");
             d=i+1;
            }
        }
            for(i=space;i<a.length();i++)
            {
                k=a.charAt(i);
                System.out.print(k);
            }
            System.out.print("\n");
            System.out.println("\nThank you for using this short program");
       
    }
}
               
       
             

2 comments:

  1. EVEN THOUGH I MODIFIED THE PROGRAM USING SCANNER CLASS;
    THANKS A LOT !!!

    ReplyDelete
  2. This feature proves valuable in various applications, from database management to user interfaces, My Unwachable Stream enhancing efficiency and user experience through concise representation of individuals' names.

    ReplyDelete

ShareThis