Question

Write a Java program that prompts the user to enter his/her name (first and last). Names...

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

Homework Answers

Answer #1
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));
    }
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Python Jupyter Notebook Write a program that prompts the user to enter his/her first name, last...
Python Jupyter Notebook Write a program that prompts the user to enter his/her first name, last name, and year of birth in a single string (in the format: fn;ln;yyyy), then calculates the age tell it to him/her after greeting him/her using the first name. Make sure to capitalize the user's first name, regardless of how he/she typed it in. Hint: review Exercise 1! Example: Enter your first name, last name, and birth year (in format fn;ln;yyyy): alex;smith;1994 Hi Alex, you...
Write a complete Java program which prompts the user of the program to input his/her first...
Write a complete Java program which prompts the user of the program to input his/her first name, then prompts the user for the middle initial and finally prompts the user for the last name. As indicated, there are three prompts to the user. The program should output the user’s name with the first name first, followed by the middle initial, and the last name last, all on one line (with appropriate spacing). If you could also pinpoint exactly where to...
Write a program In python of Jupiter notebook That prompts the user to enter his/her first...
Write a program In python of Jupiter notebook That prompts the user to enter his/her first name, last name, and year of birth in a single string (in the format: fn;ln;yyyy), then calculates the age tell it to him/her after greeting him/her using the first name. Make sure to capitalize the user's first name, regardless of how he/she typed it in. Hint: review Exercise 1! Example: Enter your first name, last name, and birth year (in format fn;ln;yyyy): alex;smith;1994 Hi...
Write a program that stores lists of names (the last name first) and ages in parallel...
Write a program that stores lists of names (the last name first) and ages in parallel arrays and sorts the names into alphabetical order keeping the ages with the correct names. Sample output:    PROGRAM: C
JAVA (Don't make it too complicated) Write a program that prompts the user for the name...
JAVA (Don't make it too complicated) Write a program that prompts the user for the name of a text file. The file should consist of a sequence of integers, one integer per line. The program will read in each line (using nextLine()), parse it as an int (using Integer.parseInt()), and report the number of values and their average. The average should be computed as a double. Your program should do some basic exception handling: (1) If the file cannot be...
Write a java program that creates an integer array with 50 random values, prompts the user...
Write a java program that creates an integer array with 50 random values, prompts the user to enter the index of an element in the array between 0 and 49, then displays the corresponding element value. If the specified index is out of bounds, display an error message (e.g. “Out of Bounds”) and ask the user to enter another index. Use a while loop that will keep prompting the user until a valid input is received. To handle invalid inputs,...
Write a program that allows the user to enter the last names of five candidates in...
Write a program that allows the user to enter the last names of five candidates in a local election and the votes received by each candidate. The program should then output each candidate’s name, votes received by that candidate, and the percentage of the total votes received by the candidate. Your program should also output the winner of the election. A sample output is as follows: Candidate Johnson Miller Duffy Robinson Sam Votes Received 5000 4000 6000 2500 1800 19300...
DATA STRUCTURE /C++ Write a program that allows the user to enter the last names offive...
DATA STRUCTURE /C++ Write a program that allows the user to enter the last names offive candidates in a local election and the votes received by each candidate. The program should then output each candidate’s name, votes received by that candidate, and the percentage of the total votes received by the candidate. Your program should also output the winner of the election. A sample output is as follows: Candidate Johnson Miller Duffy Robinson Sam Total Votes Received 5000 4000 6000...
B.2. Write a Java program to display a dialog box that asks you to enter your...
B.2. Write a Java program to display a dialog box that asks you to enter your user name and the age as shown below: The program displays in a dialog box the sum of digits of your age. For example, if you age is 19, the sum will be 1+9 = 10 and the output will be as shown below: ( it just shows a message box that says the sum of the digits age of john is 10.
**JAVA LANGUAGE** Write a program that models an employee. An employee has an employee number, a...
**JAVA LANGUAGE** Write a program that models an employee. An employee has an employee number, a name, an address, and a hire date. A name consists of a first name and a last name. An address consists of a street, a city, a state (2 characters), and a 5-digit zip code. A date consists of an integer month, day and year. All fields are required to be non-blank. The Date fields should be reasonably valid values (ex. month 1-12, day...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT