Please enable JavaScript to use CodeHS

AP Computer Science A (Nitro)

Lesson 1.5 User Input

Description

In this lesson, students will learn how to receive user input with the Scanner class in Java. After creating a new Scanner object, they will learn the commands below that will allow them to take in data from the user.

String name = input.nextLine();
int number = input.nextInt();
double decimal = input.nextDouble();

Objective

Students will be able to:

  • import and initialize a new Scanner to take in user input
  • create variables that take the assigned value of the user input.
  • choose the correct command that will allow the program to receive the input value that corresponds with its desired data type

Enduring Understandings

This lesson builds toward the following Enduring Understandings (EUs) and Learning Objectives (LOs). Students should understand that…

  • EU (Var-1) To find specific solutions to generalizable problems, programmers include variables in their code so that the same algorithm runs using different input values. (LOs 1.A, 1.B)