002-002-010
Reading Strings with Spaces Using readLine
Medium
Problem Description
Reading Strings with Spaces Using readLine
In this problem, you will create a program that reads a full name containing spaces using nextLine(), splits it into first name, last name, and total character count, and displays the result to standard output.
Learning Objective: Understand how to read strings containing spaces with nextLine() and perform string operations
Overview
Create a program that reads a full name (space-separated first and last name) in one line and performs string splitting and output.
Specifications
- Read the full name with
nextLine() - Split by space to get first and last name
- Print
Full name: <input> - Print
First: <first> - Print
Last: <last> - Print
Length: <length>(total character count including space)
Input Example
John Smith
Output Format
Full name: John Smith
First: John
Last: Smith
Length: 10
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up