Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64f39d73e1 | ||
|
|
8c5d233def |
No files matched your search
+2
-2
@@ -11,9 +11,9 @@ void main() {
|
|||||||
System.out.println("Cuantos carácteres a leer?");
|
System.out.println("Cuantos carácteres a leer?");
|
||||||
int n = sc.nextInt();
|
int n = sc.nextInt();
|
||||||
sc.nextLine();
|
sc.nextLine();
|
||||||
System.out.println("Introduce los carácteres (uno por línea): ");
|
System.out.println("Introduce los carácteres: ");
|
||||||
do {
|
do {
|
||||||
char c = sc.nextLine().charAt(0);
|
char c = sc.next().charAt(0);
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'a', 'e', 'i', 'o', 'u':
|
case 'a', 'e', 'i', 'o', 'u':
|
||||||
result++;
|
result++;
|
||||||
|
|||||||
@@ -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();
|
||||||
|
}
|
||||||
Reference in new issue
Block a user