Advertisement
josemld

signo_zodiacal

Mar 22nd, 2024
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.58 KB | Source Code | 0 0
  1. #!/bin/bash
  2.  
  3. # Función para determinar el signo zodiacal
  4. get_zodiac_sign() {
  5.     month=$1
  6.     day=$2
  7.  
  8.     case $month in
  9.         1)
  10.             if [ $day -ge 20 ]; then
  11.                 echo "Acuario"
  12.             else
  13.                 echo "Capricornio"
  14.             fi
  15.             ;;
  16.         2)
  17.             if [ $day -ge 19 ]; then
  18.                 echo "Piscis"
  19.             else
  20.                 echo "Acuario"
  21.             fi
  22.             ;;
  23.         3)
  24.             if [ $day -ge 21 ]; then
  25.                 echo "Aries"
  26.             else
  27.                 echo "Piscis"
  28.             fi
  29.             ;;
  30.         4)
  31.             if [ $day -ge 20 ]; then
  32.                 echo "Tauro"
  33.             else
  34.                 echo "Aries"
  35.             fi
  36.             ;;
  37.         5)
  38.             if [ $day -ge 21 ]; then
  39.                 echo "Géminis"
  40.             else
  41.                 echo "Tauro"
  42.             fi
  43.             ;;
  44.         6)
  45.             if [ $day -ge 21 ]; then
  46.                 echo "Cáncer"
  47.             else
  48.                 echo "Géminis"
  49.             fi
  50.             ;;
  51.         7)
  52.             if [ $day -ge 23 ]; then
  53.                 echo "Leo"
  54.             else
  55.                 echo "Cáncer"
  56.             fi
  57.             ;;
  58.         8)
  59.             if [ $day -ge 23 ]; then
  60.                 echo "Virgo"
  61.             else
  62.                 echo "Leo"
  63.             fi
  64.             ;;
  65.         9)
  66.             if [ $day -ge 23 ]; then
  67.                 echo "Libra"
  68.             else
  69.                 echo "Virgo"
  70.             fi
  71.             ;;
  72.         10)
  73.             if [ $day -ge 23 ]; then
  74.                 echo "Escorpio"
  75.             else
  76.                 echo "Libra"
  77.             fi
  78.             ;;
  79.         11)
  80.             if [ $day -ge 22 ]; then
  81.                 echo "Sagitario"
  82.             else
  83.                 echo "Escorpio"
  84.             fi
  85.             ;;
  86.         12)
  87.             if [ $day -ge 22 ]; then
  88.                 echo "Capricornio"
  89.             else
  90.                 echo "Sagitario"
  91.             fi
  92.             ;;
  93.         *)
  94.             echo "Fecha de nacimiento inválida"
  95.             ;;
  96.     esac
  97. }
  98.  
  99. # Solicitar el nombre de la persona
  100. read -p "Ingrese el nombre de la persona: " name
  101.  
  102. # Solicitar la fecha de nacimiento (DIA y MES)
  103. read -p "Ingrese la fecha de nacimiento (DIA MES): " date
  104.  
  105. # Extraer el día y el mes de la cadena de entrada
  106. day=$(echo $date | cut -d ' ' -f1)
  107. month=$(echo $date | cut -d ' ' -f2)
  108.  
  109. # Obtener el signo zodiacal
  110. sign=$(get_zodiac_sign $month $day)
  111.  
  112. # Mostrar el resultado
  113. echo "El signo zodiacal de $name es: $sign"
  114.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement