unix commands and details about unix kernalFull description
yesFull description
Full description
Deskripsi lengkap
Descripción completa
Descripción completa
Full description
linux operatin systems explained
ALL Unix commandsDescrição completa
Full description
Descripción: Tru64 Unix Installation Guide
1. Write a Bourn shell script dTOe which takes as an input any number between 0 and 999 and prints the English value for this number. The program should display an error message when a NOT digit value entered. ANSWER CODE:
#!/bin/bash # FILE NAME: dTOe.sh clear # Three different arrays are defined here with the values stored in them. UNITARRAY=(ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE TEN) ELEARRAY=(ELEVEN TWELEVE THIREEN FOURTEEN FIFTEEN SIXTEEN SEVENTEEN EIGHTEEN NINETEEN) TYSARRAY=(TEN TWENTY THIRTY FOURTY FIFTY SIXTY SEVENTY EIGHTY NINTY)
#Varibles declared as null. num="" count="" words=""
#Prompting user to give input echo "Enter the number you want to Print in words" read num # user has to give input
#checks if the input number is greater than 0 and less than or equal to 999 if [[ "$num" -ge 0 ]] && [[ "$num" -le 999 ]] then #checks if the number is 0, then Print in words. if [[ "$num" -eq 0 ]] then echo "ZERO" fi
# checks if the number is greater than 100. if [[ "$num" -ge 100 ]] then count=`expr $num / 100` num2=`expr $num % 100` words="${UNITARRAY[$count - 1]} "HUNDRED"" if [[ "$num2" -gt 0 ]] then words="$words AND" fi num=$num2 fi # checks for the condition if number is greater than 10 & less than 20. if [[ "$num" -gt 10 ]] && [[ "$num" -lt 20 ]] then count2=`expr $num % 10` index2=`expr $count2 - 1` words="$words ${ELEARRAY[$index2]}"
# checks for the condition if the number is greater than 19 elif [[ "$num" -gt 19 ]] then count3=`expr $num / 10` num3=`expr $num % 10` index3=`expr $count3 - 1` words="$words ${TYSARRAY[$index3]}" num=$num3 fi
# checks for the condition if the number is equal or greater than 0 if [[ "$num" -gt 0 ]] then words="$words ${UNITARRAY[$num - 1]}" fi echo "$words" else echo "Please enter numbers from 0 to 999 only. Try again." Fi