Write a Java program that prompts the user to enter his/her name (first and last). Names are often expressed alphabetically as last name comma space first name. Display the user's alphabetical name and its length. Then output the user's initials. Finally, display the ASCII values of the initials with a space between them. Sample Output (input shown in italics) Enter your full name Jane Doe Your alphabetical name Doe, Jane is 9 characters long Your initials are JD ASCII of your initials : 74 68
Enter your full name
Jane Doe
Your alphabetical name Doe, Jane is 9 characters long
Your initials are JD
ASCII of your initials : 74 68
import java.util.Scanner; public class Username { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("Enter your full name"); String first = in.next(), last = in.next(); String alphabetical = last + ", " + first; System.out.println("Your alphabetical name " + alphabetical + " is " + alphabetical.length() + " characters long"); System.out.println("Your initials are " + first.charAt(0) + last.charAt(0)); System.out.println("ASCII of your initials : " + (int)first.charAt(0) + " " + (int)last.charAt(0)); } }
Get Answers For Free
Most questions answered within 1 hours.