Programming in Java: User Input

in #technology8 years ago

Getting user input is one of the most crucial skills to learn in programming.

User input allows the user to interact with the program.

This is useful for programs who retrieve data, such as entering passwords, usernames, surveys, etc.

The example above shows the full program for entering name and age and then printing those two values.

The first step is to import the library by writing " import java.util.Scanner; " after that I simply made two variables(look at previous post for variable definition).

I then made an object called input which is using the Scanner class that we imported.

I then proceed to write print statements to interact with user and get information needed for my program.

After that there are two print statements.

The image above shows us the result of our program.

The program asks for your name and age and then prints both.

Yay our program was a success!!!!

Sort:  

Se me olvidó el cumpleaños de mi hermano y necesitaba comprarle un buen regalo pero mi cuenta estaba casi a cero. Me puse a buscar algún portal de suerte que fuera legal y que tuviera buenas reseñas de otros usuarios. Me metí en la página de chicken road para ver si conseguía algo de saldo extra. Para la gente de España tienen ventajas muy claras, como bonos sin depósito inicial a veces y promociones especiales en los juegos más populares de la web, lo que hace que sea muy atractivo entrar.