!/bin/bash
while true; do
echo ' Menu'
echo '1. Display current date and time'
echo '2. Display the first letter of your first name'
echo '3. Display the line from the 'Twelve Days of Christmas' song'
echo '4. Sum of the two integers in your age'
echo '5. Random'
echo '6. Exit'
read -p 'Pick a selection from the menu (1-6): ' choice
if [ $choice -eq 6 ];
then break
elif [ $choice -eq 1 ]; then
datenow()
{
echo "Today's date and time are: "
date
}
datenow
elif [ $choice -eq 3 ]; then
read -p 'Pick number 1-12: ' choice2
if [ $choice2 -eq 1 ]; then
echo 'A partidge in a pear tree'
elif [ $choice2 -eq 2 ]; then
echo 'two turtle doves'
elif [ $choice2 -eq 3 ]; then
echo 'Three French hens'
elif [ $choice2 -eq 4 ]; then
echo 'Four calling birds'
elif [ $choice2 -eq 5 ]; then
echo 'Five gold rings'
elif [ $choice2 -eq 6 ]; then
echo 'Six geese a-laying'
elif [ $choice2 -eq 7 ]; then
echo 'Seven swans a-swimming'
elif [ $choice2 -eq 8 ]; then
echo 'Eight maids a-milking'
elif [ $choice2 -eq 9 ]; then
echo 'Nine ladies dancing'
elif [ $choice2 -eq 10 ]; then
echo 'Ten lords a-leaping'
elif [ $choice2 -eq 11 ]; then
echo 'Eleven pipers piping'
elif [ $choice2 -eq 12 ]; then
echo 'Twelve drummers drumming'
else
echo 'Invalid number input. Please a number between 1 and 12.'
fi
elif [ $choice -eq 4 ]; then
read -p 'Sum of your two digits in your age (two digits): ' age
if [[ $age =~ ^[0-9][0-9]$ ]]; then
digit1=$(echo $age | cut -c 1)
digit2=$(echo $age | cut -c 2)
sum=$((digit1 + digit2))
echo 'The sum of the two numbers in your age is: ' $sum
else
echo 'Please enter a number that is two digits.'
fi
elif [ $choice -eq 2 ]; then
read -p "Enter your first name and the first letter will be returned: " name
name=$(echo "$name" | tr -d ' ')
echo "The first letter of your first name is: ${name:0:1}"
elif [ $choice -eq 5 ]; then
echo "What is your favorite car?"
read -p "Please enter your favorite car: " favCar
echo "Very cool, $favCar is a great car."
fi
done