002-001-012

Processing Multiple Inputs with Scanner

Medium

Problem Description

Processing Multiple Inputs with Scanner

In this problem, you will create a program that reads a name (string) and age (integer) sequentially using the Scanner class and displays a self-introduction to standard output.

Learning Objective: Understand how to read multiple data types sequentially with Scanner

Overview

Create a program that reads a name (string) and age (integer) using Scanner and prints a self-introduction.

Specifications

  1. Create a Scanner object
  2. Read the name with nextLine()
  3. Read the age with nextInt()
  4. Print My name is <name>. I am <age> years old.

Input Example

Alice
25

Output Format

My name is Alice. I am 25 years old.

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