in Education by
write a Java program to accept a full name and display the initials along with the surname. URGENT! give the full program please Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
Answer: import java.util.*; public class hello { public static void main(String[] args) { Scanner scan=new Scanner(System.in); System.out.println(“Enter your full name”); String name = scan.next(); System.out.println(“The full name is: ” + name); System.out.print(“Initials with surname is: “); int len = name.length(); name = name.trim(); String str1 = “”; for (int i = 0; i < len; i++) { char ch = name.charAt(i); if (ch != ‘ ‘) { str1 = str1 + ch; } else { System.out.print(Character.toUpperCase(str1.charAt(0)) + “. “); str1 = “”; } } String str2 = “”; for (int j = 0; j < str1.length(); j++) { if (j == 0) str2 = str2 + Character.toUpperCase(str1.charAt(0)); else str2 = str2 + Character.toLowerCase(str1.charAt(j)); } System.out.println(str2); } }

Related questions

0 votes
    write a program in java to accept a number and display the new number after removing all the zeros Select the correct answer from above options...
asked Dec 10, 2021 in Education by JackTerrance
0 votes
    write a program to accept a word and display the new word after removing all the repeated alphabet Select the correct answer from above options...
asked Dec 25, 2021 in Education by JackTerrance
0 votes
    Write a program to accept a filename from the user and display all the lines from the file which contain python comment character ‘#’. Select the correct answer from above options...
asked Dec 21, 2021 in Education by JackTerrance
0 votes
    Write a JAVA program to store the marks of any 5 subjects in different variables. Calculate total and average. ... ANY INPUT METHOD Select the correct answer from above options...
asked Dec 22, 2021 in Education by JackTerrance
0 votes
    Write a JAVA program to store the marks of any 5 subjects in different variables. Calculate total and average. ... total and average. Select the correct answer from above options...
asked Nov 30, 2021 in Education by JackTerrance
0 votes
    write a java program to accept alphabet and find out vowel or consonant Select the correct answer from above options...
asked Dec 24, 2021 in Education by JackTerrance
0 votes
    Write a program which sends the name of a text file from the client to server and display the message on the ... file present or not. Select the correct answer from above options...
asked Dec 1, 2021 in Education by JackTerrance
0 votes
    Write an algorithm to accept radius of a circle from user, and display area of the circle using the formula: area ... x radius x radius Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
0 votes
    For the following data, what formula is to be used to add first name & Surname Select the correct answer from above options...
asked Dec 1, 2021 in Education by JackTerrance
0 votes
    Question No.1: What do you understand about container tag and empty tag, give example? Question No.2: What do ... all the attributes? Select the correct answer from above options...
asked Nov 29, 2021 in Education by JackTerrance
0 votes
    write a Java program to input 10 non-zero numbers in an array and display the count of even and odd numbers. URGENT! Select the correct answer from above options...
asked Dec 31, 2021 in Education by JackTerrance
0 votes
    Write a JAVA program to find the area and perimeter of a square and rectangle. Store side in s , length as ... USE ANY INPUT METHOD Select the correct answer from above options...
asked Dec 22, 2021 in Education by JackTerrance
0 votes
    Write a JAVA program to find the area and perimeter of a square and rectangle. Store side in s , length ... results in separate lines. Select the correct answer from above options...
asked Dec 21, 2021 in Education by JackTerrance
0 votes
    Write a program in java to display the given pattern. 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 Please ... as brainlist Please answer it very fast Select the correct answer from above options...
asked Dec 21, 2021 in Education by JackTerrance
0 votes
    java program to input any string then print each word along with their length Select the correct answer from above options...
asked Dec 31, 2021 in Education by JackTerrance
...