Multiply variables

I have no idea about programming, just know some simple html :confused:and I need to get to somebody that can help me with creating the application (?) that will multiply 2 varibales and given price (height x lenght) x $$$.

PLEASE HELP!:confused:

edit by bakunin: Anita, as much as we appreciate your question, i have to tell you that you posted it to the wrong forum part. This part, as the name should suggest, is a "Forum Support Area for Unregistered Users & Account Problems" an definitely not for a scripting problem such as yours.

I will transfer your post to where it belongs, but i would like to ask you to place your postings right from now on.

You can do that with a little script like the one i have written for you. It will start over and wait for input as long as Input is non-zero. If it is it will terminate.

Note that the script makes no efforts to validate the input - entering a string or another nonsensical value instead of an (integer) number will cause a error message by the shell.

#! /bin/ksh

typeset -i iLen=0
typeset -i iHgt=0
typeset -i iPrc=0

while : ; do
     read iLen?"Enter length: "
     if [ $iLen -le 0 ] ; then
          exit 0
     fi
     read iHgt?"Enter height: "
     if [ $iHgt -le 0 ] ; then
          exit 0
     fi
     read iPrc?"Enter price : "
     if [ $iPrc -le 0 ] ; then
          exit 0
     fi

     print - "\nProduct (Length x Height x Price) is: $(( iLen * iHgt * iPrc ))"
     print - "\n\n"

done

exit 0

Save this as "multiply.sh", do a "chmod 755 multiply.sh" and start it with "./multiply.sh".

I hope this helps.

bakunin

And in ksh93 syntax:

#!/bin/ksh93

integer iLen=0
integer iHgt=0
integer iPrc=0

while : ; do
     read iLen?"Enter length: "
     (( $iLen <= 0 )) && exit 0
     read iHgt?"Enter height: "
     (( $iHgt <= 0 )) && exit 0
     read iPrc?"Enter price : "
     (( $iPrc <= 0 )) && exit 0

     printf "\nProduct (Length x Height x Price) is: %d\n\n"  $(( iLen * iHgt * iPrc ))
done

exit 0