-
-
Save parzibyte/418a32a1beedd1b4497da74b94f15e6d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
____ _____ _ _ _ | |
| _ \ | __ \ (_) | | | | |
| |_) |_ _ | |__) |_ _ _ __ _____| |__ _ _| |_ ___ | |
| _ <| | | | | ___/ _` | '__|_ / | '_ \| | | | __/ _ \ | |
| |_) | |_| | | | | (_| | | / /| | |_) | |_| | || __/ | |
|____/ \__, | |_| \__,_|_| /___|_|_.__/ \__, |\__\___| | |
__/ | __/ | | |
|___/ |___/ | |
____________________________________ | |
/ Si necesitas ayuda, contáctame en \ | |
\ https://parzibyte.me / | |
------------------------------------ | |
\ ^__^ | |
\ (oo)\_______ | |
(__)\ )\/\ | |
||----w | | |
|| || | |
Creado por Parzibyte (https://parzibyte.me). | |
------------------------------------------------------------------------------------------------ | |
| IMPORTANTE | | |
Si vas a borrar este encabezado, considera: | |
Seguirme: https://parzibyte.me/blog/sigueme/ | |
Y compartir mi blog con tus amigos | |
También tengo canal de YouTube: https://www.youtube.com/channel/UCroP4BTWjfM0CkGB6AFUoBg?sub_confirmation=1 | |
Twitter: https://twitter.com/parzibyte | |
Facebook: https://facebook.com/parzibyte.fanpage | |
Instagram: https://instagram.com/parzibyte | |
Hacer una donación vía PayPal: https://paypal.me/LuisCabreraBenito | |
------------------------------------------------------------------------------------------------ | |
*/ | |
echo "1. Panamá Centro\n2. Panamá Oeste\n3. Zona Atlántica\n4.Tierras altas\nSeleccione la zona [1-4]: "; | |
fscanf(STDIN, "%d", $zona); | |
if ($zona < 1 || $zona > 4) { | |
exit("Zona no válida"); | |
} | |
echo "Ingrese la cantidad de noches a reservar:"; | |
fscanf(STDIN, "%d", $noches); | |
if ($noches < 0) { | |
exit("Las noches deben ser un número positivo"); | |
} | |
echo "Ingrese la cantidad de personas: "; | |
fscanf(STDIN, "%d", $personas); | |
if ($personas < 2) { | |
exit("Solo puede asistir en pareja o en familia"); | |
} | |
$edades = []; | |
for ($i = 0; $i < $personas; $i++) { | |
echo "Ingrese la edad de la persona #" . ($i + 1) . ": "; | |
fscanf(STDIN, "%d", $edad); | |
$edades[] = $edad; | |
} | |
// Seleccionar hotel | |
$hotel = ""; | |
if ($personas === 2) { | |
switch ($zona) { | |
case 1: | |
$hotel = "Hotel El Panamá"; | |
break; | |
case 2: | |
$hotel = "RIU Playa Blanca"; | |
break; | |
case 3: | |
$hotel = "Radisson Colon 2000"; | |
break; | |
case 4: | |
$hotel = "Valle Escondido Resort"; | |
break; | |
} | |
} else { | |
switch ($zona) { | |
case 1: | |
$hotel = "Gamboa Rainforest Resort"; | |
break; | |
case 2: | |
$hotel = "Royal Decameron"; | |
break; | |
case 3: | |
$hotel = "Hotel Cocotal"; | |
break; | |
case 4: | |
$hotel = "Boquete Garden Inn"; | |
break; | |
} | |
} | |
// Recorremos para calcular costo | |
$costo = 0; | |
foreach ($edades as $edad) { | |
if ($edad >= 12 && $edad <= 17) { | |
$costo += 15; | |
} else if ($edad >= 18) { | |
$costo += 47; | |
} | |
} | |
// Y lo multiplicamos por las noches | |
$costo *= $noches; | |
echo "Su reserva es en el hotel " . $hotel . "\n"; | |
echo "El costo total es: " . $costo; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment