Write a program in Java to input a name and display :Mohandas Karamchand Gandhi
Answers
Answered by
13
Explanation:
Sample Input : Mohandas Karamchand Gandhi
Sample Output : M K Gandhi
class InitialsWidName
{
static void teja(String st)
{
int l = st.length();
String bin=””;
System.out.print(st.charAt(0));
for(int i=0;i<l;i++)
{
char ch=st.charAt(i);
if(Character.isWhitespace(ch))
System.out.print(” “+st.charAt(i+1));
}
int s =st.lastIndexOf(‘ ‘);
System.out.print(st.substring(s+2,l));
}
}
Similar questions