002-001-011

Scanner Basics: User Name Input

Easy

Problem Description

Scanner Basics: User Name Input

In this problem, you will create a program that reads a single line of text from standard input using the Scanner class and displays a "Hello, [name]!" greeting message to standard output.

Learning Objective: Understand how to read strings from standard input using the Scanner class

Overview

Create a program that uses the Scanner class to read a user's name from standard input and output a greeting message using that name.

Specifications

  • Import java.util.Scanner
  • Create a Scanner object using System.in as the argument
  • Read a single line of text from standard input using the nextLine() method
  • Output "Hello, [name]!" using the read name

Input Format

Alice

Output Format

Hello, Alice!

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