Question: You can read a string from the console: System.out.print ( Please enter your name: ) ; String name = in . next (

You can read a string from the console:
System.out.print("Please enter your name: "); String name = in.next();
When a string is read with the next method, only one word is read. For example, suppose the user types
Harry Morgan
as the response to the prompt. This input consists of two words. The call in.next() yields the string "Harry". You can use another call to in.next() to read the second word.
CHALLENGEACTIVITY
2.13.1: Write a program that reads two words of input and prints them in reverse order.
553700.4397796.qx3zqy7
Write a program that reads in the first and last name of a person and prints the last name, followed by a comma, a space, and the first name. For example:
Please enter your first and last name: Harry Morgan Morgan, Harry

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!