Untitled Document
Decision Control Structure
1. Program - To determine whether Year entered is Leap Year or not Click Here
       #!/bin/ksh 
       #********* Source Code From Website - Mangadaku - visit us at -http://mangadaku.com/ *****      
       # Program To Determine Leap year
       
       echo " Enter The Year "
       read year
       
       leap_yr=`expr $year%4`
       if [[ $leap_yr -eq 0 ]]; then
       
       echo " The year $year is a leap year "
       else 
       
       echo " The year $year is not a leap year "
       fi
       
2. Program - To Display The library Penalty Charges based on due dates Click Here
       #!/bin/ksh 
       #********* Source Code From Website - Mangadaku - visit us at -http://mangadaku.com/ *****      
       # Program To Print Library Fine For Students
       
       echo " Please Enter The Days "
       read day
       
       if [[ $day -le "5" ]]; then
       fine=" 0.5 Rs "
       
       echo " For $day Days Fine is :: $fine "
       fi
       
       if [[ $day -ge "6" && $day -le "10" ]]; then 
       fine=" 1 Rs "       
       echo " For $day Days Fine is :: $fine "
       fi
             
       if [[ $day -gt "10" && $day -le "30" ]]; then 
       fine=" 5 Rs "       
       echo " For $day Days Fine is :: $fine "
       fi
       
       if [[ $day -gt "30" ]]; then  
       echo " Sorry !! Your Membership is Cancelled "
       fi
       
       
3. Program - To check if two nos are not given then script should show error and its usage Click Here
       #!/bin/ksh 
       #********* Source Code From Website - Mangadaku - visit us at -http://mangadaku.com/ *****      
       # Program To check if two nos are not given then script should show error and its usage
       if [ $# -ne 2 ]
           then
                echo "Usage - $0   x    y"
                echo "Where x and y are two nos for which We will print sum"
           exit 1
        fi
           echo "Sum of $1 and $2 is `expr $1 + $2`"
         
       
4. Program - To find out biggest number from given three nos.  Click Here
       #!/bin/ksh 
       #********* Source Code From Website - Mangadaku - visit us at -http://mangadaku.com/ *****      
       # Program To find out biggest number from given three nos.
        
        if [ $# -ne 3 ]
        then
	        echo "$0: number1 number2 number3 are not given"
        exit 1    
        fi
   
            n1=$1
            n2=$2
            n3=$3
         if [ $n1 -gt $n2 ] && [ $n1 -gt $n3 ]
         then
	         echo "$n1 is Bigest number"
         elif [ $n2 -gt $n1 ] && [ $n2 -gt $n3 ]         
         then
	         echo "$n2 is Bigest number"
         elif [ $n3 -gt $n1 ] && [ $n3 -gt $n2 ]         
         then
             echo "$n3 is Bigest number"
         elif [ $1 -eq $2 ] && [ $1 -eq $3 ] && [ $2 -eq $3 ]
         then
	         echo "All the three numbers are equal"    
         else
             echo "I can not figure out which number is biger"    
         fi    
       
5. Program - To determine whether given file exist or not Click Here
       #!/bin/ksh 
       #********* Source Code From Website - Mangadaku - visit us at -http://mangadaku.com/ *****      
       # Program To determine whether given file exist or not
      
         if [ $# -ne 1 ]
         then
             echo "Usage - $0  file-name"
         exit 1
         fi

             if [ -f $1 ]
             then
                 echo "$1 file exist"
             else
                 echo "Sorry, $1 file does not exist"
             fi
       
6. Program - To determine whether given number is odd or even Click Here
       #!/bin/ksh 
       #********* Source Code From Website - Mangadaku - visit us at -http://mangadaku.com/ *****      
       # To determine whether given number is odd or even
       
       echo " Enter The Number "
       read num
       
       num_mod=`expr $num%2`
       if [[ $num_mod -eq 0 ]]; then
       
       echo " The Number $num is an even number "
       else 
       
       echo " The year $num is an odd number "
       fi
       
7. Program - To determine whether the triangle is valid or not ( Hint - sum of all the three angles should be 180 degree ) Click Here
       #!/bin/ksh 
       #********* Source Code From Website - Mangadaku - visit us at -http://mangadaku.com/ *****      
       # To determine whether the triangle is valid or not
       
       if [ $# -ne 3 ]
       then 
       echo " $0 - Usage - Please enter 3 angles "
       exit 1 
       
       else 
       
       sum=`expr $1+$2+$3`
       if [[ $sum -eq 180 ]]; then
       
       echo " The Trianngle is a Valid Triangle "
       else 
       
       echo " The Trianngle is not a Valid Triangle "
       fi
       fi
       
Untitled Document