-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathCiclos2.java
More file actions
38 lines (30 loc) · 957 Bytes
/
Ciclos2.java
File metadata and controls
38 lines (30 loc) · 957 Bytes
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
27
28
29
30
31
32
33
34
35
36
37
38
import java.util.Scanner;
public class Ciclos2 {
public static void main(String args[]) {
Scanner scanner = new Scanner(System.in);
// Ejemplo 1
int contador = 0;
do {
System.out.println("Contador: " + contador);
contador++;
} while (contador < 5);
// ejemplo 2
// insertar moneda
// en un arcade
String insertoMoneda;
do {
System.out.println("¿Deseas continuar el juego?");
insertoMoneda = scanner.nextLine();
} while (insertoMoneda.equals("si"));
scanner.close();
// Tecer ejemplo
// Salud de un jugador
// de arcade
int saludJugador = 10;
do {
System.out.println("Estas siedo atacado! Te quedan: " + saludJugador + " puntos");
saludJugador -= 2;
} while (saludJugador > 0);
System.out.println("Game Over!!!");
}
}