-
Notifications
You must be signed in to change notification settings - Fork 0
/
Actividad1.java
26 lines (20 loc) · 976 Bytes
/
Actividad1.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import java.util.Scanner;
public class Actividad1 {
// Para entender mejor el concepto de esta clase, practicarás con los siguientes ejercicios:
//
// Solicita al usuario que ingrese su nombre (cadena de texto), guárdalo en una variable e imprime el dato por consola..
// Solicita al usuario que ingrese su edad (número), guárdalo en una variable e imprime el dato por consola..
// Luego imprime en pantalla un mensaje que diga “Su nombres es [nombre del usuario] y su edad es [edad del usuario]”.
private String nombre;
private int edad;
public void pedirDatos() {
Scanner scanner = new Scanner(System.in);
System.out.print("Por favor, ingresa tu nombre: ");
nombre = scanner.nextLine();
System.out.print("Por favor, ingresa tu edad: ");
edad = scanner.nextInt();
}
public void mostrarDatos() {
System.out.println("Su nombre es " + nombre + " y su edad es " + edad + ".");
}
}