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

  1. Read the full name with nextLine()
  2. Split by space to get first and last name
  3. Print Full name: <input>
  4. Print First: <first>
  5. Print Last: <last>
  6. 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