1. Java Program to Convert a Person Name in Abbreviated.
2. wap to print the short name of the user.
3. Java program to convert full name to short name.
4. Java program to a short name.
5. Abbreviation of Java programming language.Problem:-
Enter Name: Anant Deep Vishwakarma
Output: A. D. VishwakarmaSolutions:-
1. Store Name in a name String.
2. Split Name String and Store to a temp string array.
3. Find temp string array length store value in other variables.
4. Take a loop to store all value to expect the last name and print the first character by value with
dot or abbreviation.
5. then print the last value of temp string all Character
Explain:
For example a store name ‘Anant Deep Vishwakarma’in a name string and then split value into temp string array as temp[0]=’Anant’, temp[1]=’Deep’ and temp[2]=’Vishwakarma’, after that count length of temp string array and use loop to left the last index value last name ‘Vishwakarma’, in loop print first char of every index value within loop. in the last print last index of program
Best java program example:
class SName
{
public static void main(String[] args)
{
String n;
Scanner c=new Scanner(System.in);
System.out.print(“Enter the user name:”);
n=c.nextLine();
String [] t=n.split(” “);
int l=t.length;
System.out.print(“Your Short name:”);
for(int i=0;i
System.out.print(t[i].charAt(0)+”.”);
}
System.out.print(t[l-1]);
}
}
I hope you understand the program is any queries please comment below your query I reply to your questions soon.
Bye…
Happy coding