Java program: Your job is to write a program that does the following: Prompts the user to enter their name

Java program: Your job is to write a program that does the following: Prompts the user to enter their name. Displays a greeting to the user with their first name only. Transcribed Image Text: Sample run
Input:
Snoopy
Run:
What is your name? Snoopy
Hello Snoopy!
Notes
• In the sample run, there is a space between the question mark and the input entered by the user. Since you are supposed to exactly
match the output, don’t forget to include a space there. Also, make sure to use a println Sstatement to print the last line of the output.
• There are two methods that you can use to read in strings from the console. The first is called nextLine. This method reads the rest
of the entire line. This is good when you know you want to read a few pieces of information or that there is only a single piece of
information on that line. However, this method would not be good if you wanted to just read in the word “Donald” when the user
inputs “Donald Trump”. In this case, nextLine would read in the entire full name. The other method for reading is called next. This
method reads up until a whitespace (e.g., blank). This method is great when you just need to read in a piece of data on a line that’s a
string. In other words, using next after the user types in “Donald Trump” would give just the “Donald”. That should be the approach
you take here for this program since we are not guaranteed the user will enter just a first name . they might enter a full name and we
only want the first name. Transcribed Image Text: It is highly likely that the output is still not exactly as specified. Note that the sample run above includes both output (what the program
prints out) and input (what the user enters). Remember that when the user enters a value, they will press Enter key after the value is typed.
Hence, a more detailed sample run would be the following where the is represented by e.
Keep in mind that the user types “Snoopy”, not your program.
What is_your name? Snoopy!
HelloISnoopy!
—-
But on this line you echo back whatever the user typed in as the name..it may not be “Snoopy”.
If the user types Snoopy and presses Enter, then the input part of the sample run above is Snoopye. That would mean the output part would
be everything else: the question “What is your name? ” (including the space after the question mark) and the sentence, “Hello Snoopy”. This
is why the expected output of the first test case in Submit mode is the following, which doesn’t include the input:
What is your name? Hello Snoopy.

-25-


Buy plagiarism free, original and professional custom paper online now at a cheaper price. Submit your order proudly with us



Essay Hope