-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava_If_Else.java
More file actions
27 lines (21 loc) · 1.06 KB
/
Java_If_Else.java
File metadata and controls
27 lines (21 loc) · 1.06 KB
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 Java_If_Else{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
//Java admite las condiciones lógicas habituales de las matemáticas:
//Utilice la if declaración para especificar un bloque de código Java que se ejecutará si una condición es true.
System.out.println("===== SIMULADOR DE SEGURIDAD =======");
System.out.print("Ingrese su Edad : ");
int num = scan.nextInt();
if(num < 18 || num > 80){
System.out.println("Lo sentimos, no tiene permitido ingresar al Local");
}else{
System.out.println("¡¡Disfrute esta nueva experiencia en nuestro Local!!");
//Genero un num que inddicará el número de asiento del cliente
int asiento = (int)(Math.random()*(10-1+1)) + 1;
//Java Short Hand If...Else
String direccion = (asiento%2 == 0) ? "Derecha" : "Izquierda";
System.out.println("Dirijase a la " + direccion);
}
}
}