Академический Документы
Профессиональный Документы
Культура Документы
import java.util.Scanner;
String nombre;
Scanner scanner = new Scanner(System.in);
System.out.println("Ingrese un nombre.");
nombre = scanner.nextLine();
System.out.println("El nombre ingresado es: " + nombre.toUpperCase());
}
}
import java.util.Scanner;
System.out.println("Ingrese un nombre.");
nombre = scanner.nextLine();
nom = nombre.toLowerCase();
nombre = nom.substring(0,1).toUpperCase() + nom.substring(1, nom.length());
System.out.println("Ingrese un apellido.");
apellido = scanner.nextLine();
ap = apellido.toLowerCase();
apellido = ap.substring(0,1).toUpperCase() + ap.substring(1, ap.length());
System.out.println("El nombre ingresado es: " + nombre + " " + apellido);
}
}
import java.util.Scanner;
do {
System.out.println("Ingrese el mes.");
mes = scanner.nextInt();
if (mes < 1 | mes > 12) System.out.println("Mes ingresado
incorrecto.");
} while (mes < 1 || mes > 12);
if (mes < 10) mesFecha = "0" + Integer.toString(mes);
else mesFecha = Integer.toString(mes);
do {
System.out.println("Ingrese el año.");
año = scanner.nextInt();
if (año < 1) System.out.println("Año ingresado incorrecto.");
} while (año < 1);
if (año < 1000 && año >= 100) añoFecha = "0" + Integer.toString(año);
else if (año < 100 && año >= 10) añoFecha = "00" + Integer.toString(año);
else if (año < 10) añoFecha = "000" + Integer.toString(año);
else añoFecha = Integer.toString(año);
}
}
import java.util.Scanner;
String nombre;
Scanner scanner = new Scanner(System.in);
System.out.println("Ingrese un nombre.");
nombre = scanner.nextLine();
System.out.println("El nombre ingresado es: " + nombre.toUpperCase());
System.out.println("El nombre tiene " + nombre.length() + " caracteres.");
}
}
import java.util.Scanner;
String numero;
String inverso = "";
Scanner scanner = new Scanner(System.in);
do {
System.out.println("Ingrese un numero de 4 dígitos.");
numero = scanner.nextLine();
if (numero.length() < 4 || numero.length() > 4 ) System.out.println("El
número ingresado es incorrecto.");
} while (numero.length() < 4 || numero.length() > 4 );
}
}
import java.util.Scanner;
int numero;
Scanner scanner = new Scanner(System.in);
}
}
import java.util.Scanner;
public class TablaDeMultiplicar {
int numero, i;
Scanner scanner = new Scanner(System.in);
i = 1;
while (i<13) {
System.out.println(numero + "x" + i + "= " + (numero*i));
i++;
}
}
}
import java.util.Scanner;
int numero, i;
Scanner scanner = new Scanner(System.in);
i = 1;
do {
System.out.println(numero + "x" + i + "= " + (numero*i));
i++;
} while (i<13);
}
}
// 9.- Cuál es la instrucción Java que debemos usar para crear la clase alumnos.
// Declaración de atributos.
[visibilidad] + [modificadores] + tipo + nombre_atributo;
// Declaración de métodos.
[visibilidad] + [modificadores] + tipo + nombre_metodo ([parámetros]) {}
// [visibilidad] = public, protected o private
// [modificadores] = final, static y abstract
// 10.- En la instrucción public class persona, hay 2 errores, cuáles son? (ojo
tiene trampa)
Faltan las llaves o corchetes --> {}. Además, es buena práctica comenzar el nombre
de las clases con mayúscula, por lo que en este caso debería ser "Persona" y no
"persona".