Wednesday, 4 June 2014

Java program which gives initials of your name

import java.io.*;
class initials
{
    public static void main(String ar[])throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        System.out.println("enter a name");
        String s=br.readLine();
        int l=s.length();
        char k;
        char a[]=new char[l];
        for(int i=0;i<l;i++)
        {
            a[i]=s.charAt(i);
        }
        System.out.println(a[0]);
        for(int i=0;i<=l-1;i++)
        {
            if(a[i]==' ')
        {
        System.out.println(a[i+1]);
        }
        }
    }
}
   

No comments:

Post a Comment