Results 1 to 3 of 3
- 03-19-2011, 11:24 AM #1
Member
- Join Date
- Mar 2011
- Posts
- 6
- Rep Power
- 0
A java program to print short form of a name.
import java.io.*;
public class Netaji
{
public static void main()throws IOException
{
InputStreamReader reader=new InputStreamReader(System.in);
BufferedReader input=new BufferedReader(reader);
System.out.println("Enter your name please");
String a=input.readLine();
int count=a.length();
int i=1,adprint;
char pchar,hold;
for(i=1;i<=count;i++)
{
hold=a.charAt(i);
if(i==1)
{
pchar=a.charAt(0);
System.out.print(pchar+".");
}
else if(hold==' ')
{
adprint=i+1;
pchar=a.charAt(adprint);
System.out.print(pchar+".");
}
}
}
}
- 03-19-2011, 01:37 PM #2
Did you have a question, or is this just an exhibition of your l33t sk1llz?
Recommended reading:
Code Conventions for the Java(TM) Programming Language: Contents
How To Ask Questions The Smart Way
And use code tags to post code.
db
-
Similar Threads
-
short message service (SMS in java)
By ashin in forum Advanced JavaReplies: 4Last Post: 06-04-2011, 07:59 AM -
short month = Short.parseShort(splitarray[2].toString()));
By AndyC in forum New To JavaReplies: 3Last Post: 02-20-2011, 12:15 PM -
Very newbie trying to run form program
By projecttoday in forum New To JavaReplies: 2Last Post: 01-12-2011, 06:28 AM -
Java code that connects one form to the other form.
By kiz106 in forum New To JavaReplies: 1Last Post: 05-27-2010, 09:48 PM -
how to print out lines in a table- like form?
By helloworld in forum New To JavaReplies: 5Last Post: 02-10-2009, 09:31 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks