#!/bin/bash
clear
# Asks for your last name
echo -n "Enter last name: "
read lname
echo $lname
echo ""
#Display “Your <lastname> has <number> of characters”
echo "your $lname has `echo $lname | wc -c ` characters." #execute command between ` ` & then substitue its output in the echo string
echo ""
#Ask your age
echo -n "Enter age: "
read age
echo $age
first=${age:0:1}
second=${age:1:1}
if [ $age -le 10 ]; then
echo "0"
#age=0
else
if [ $age -gt 99 ]; then
echo "10"
# age=10
fi
fi
echo ""
#Mulitply the first digit by 5
first=`echo $first*5 | bc`
#If your are older than 25 then add 3 to first digit*5, if you are younger than 25 add 6 to first digit*5
if [ $age -gt 25 ]; then
#y=($first+3)*5
first=`echo "$first + 3 " | bc`
else
#if you are younger than 25 add 6 to first digit*5
#if [ $age -le 25 ]; then # this if is redundant as the comparison was done above
# y=($first+6)*5
first=`echo "$first + 6" | bc`
#fi
fi
echo ""
#y=y*2
#Double your answer
first=`echo "$first * 2" | bc `
echo ""
#declare -i second
#second=11
#Add the second digit of your age
age=`echo "$first + $second" | bc `
#If you are are older than 25 then subtract 6, if you are younger than 25 then subtract 12
if [ $age -gt 25 ]; then
age=`echo "$age-6 "| bc`
else
#if [ $age -le 25 ]; then # this if is redundant as the comparison was done above
age=`echo " $age-12" | bc `
#fi
fi
echo "Your age is: $age"