Compare commits

..
2 Commits
Author SHA1 Message Date
PC de clase 64f39d73e1 corregir tokenizacion ejercicio 13 de bucles 2026-10-05 13:06:04 +02:00
PC de clase 8c5d233def Adivina el número aleatorio 2026-10-05 11:48:20 +02:00
2 changed files with 27 additions and 2 deletions

No files matched your search

+2 -2
View File
@@ -11,9 +11,9 @@ void main() {
System.out.println("Cuantos carácteres a leer?");
int n = sc.nextInt();
sc.nextLine();
System.out.println("Introduce los carácteres (uno por línea): ");
System.out.println("Introduce los carácteres: ");
do {
char c = sc.nextLine().charAt(0);
char c = sc.next().charAt(0);
switch (c) {
case 'a', 'e', 'i', 'o', 'u':
result++;
+25
View File
@@ -0,0 +1,25 @@
// Diseña un alrogitmo que cree un número aleatorio y te permita
// itroducir otros números hasta que lo adivines.
void main() {
Scanner sc = new Scanner(System.in);
Random r = new Random();
int secreto = r.nextInt(100) + 1; // 1-100
boolean interruptor = true;
int n;
do {
System.out.println("Adivina el número (1-100)");
n = sc.nextInt();
if (n > secreto) {
System.out.println("Te has pasado");
} else if (n < secreto) {
System.out.println("Te has quedado corto");
} else {
System.out.println("Has acertado!!!");
interruptor = false;
}
} while (interruptor);
sc.close();
}