statement

I want to write a program that would convert yard to feet and feet to yard.
i.e
1 yard = 3 * feet
Echo "enter a"
read a
expr a *3

The trick is that I want to give the user some options. After the conversion from yard to feet is done, I want to ask the user whether or not he/she wants to also convert from feet to yard. If the user says yes, then the script should be executed and the conversion from feet to yard done. But the user says no, the program should stop and exit out.

I need some ideas.

This sounds like homework. If it is, you should make an effort to write the script. If you then need help, post what you have written, and ask a more detailed question concerning your problem.

If it isn't homework, you should still make the effort.

Well, If you are not aware of this then you must read this link

Actually, It is not a homework. I left school a long time ago :). Anyways, I am just trying to develop some unix skills especially when it comes to scripting. I am writing simple programs on my own, but am asking for some help after many trials and I cannot get it to work.
If you think it is too easy for me to request the forum's input. I apologize for my ignorance.

I am guessing I need to use a maybe "if statement", but I am not sure. I have tried (if,then,elseif,fi) to no avail. I get many error messages.

I am looking to write a statement that allow me to contimue when the user enters Yes and exit the program if the user enters no. Let me know whta you guys think. what is wrong with my if statement?

cat conversion
#! /usr/bin/ksh
echo "This program is designed to do measurement conversion"
echo "Enter yard"
read yard
echo "The result in feet is:"
expr $yard '*' 3
echo "Do you want to convert from feet to yard as well?"
echo "Please enter your answer"
echo "please enter yes to continue or no to exit:"
read
if
($answer = yes) &&

echo "You have entered yes:"
then
echo "please enter feet"
read feet
echo "The result in yard is:"
expr $feet / 3
else
clear
fi

What you need is a while loop. I'd write it so that it is an infinite loop, with a break statement to exit the loop when the user is done. Here is the basic form:

while true
do
  # your main routine goes here

  printf "%s " "Another conversion?"
  read continue
  case $continue in
    [yY]*) ;;
    *) printf "%s\n" "Good-bye"
        break
        ;;
  esac
done

I am still having the same issue. Whether I enter yes or no, the program prompts me to enter feet without exiting. I want the program to exit when the user enters no. What is still missing?

#! /usr/bin/ksh
echo "This program is designed to do measurement conversion"
echo "Enter yard"
read yard
echo "The result in feet is:"
expr $yard '' 3
echo "Do you want to convert from feet to yard as well?"
echo "Please enter your answer"
echo "please enter yes to continue or no to exit:"
read
while true
do
printf "%s " " Enter feet?"
read feet
echo "The result in yard is:"
expr $feet / 3
read continue
case $continue in
[yy]
) ;;
*) printf "%s\n" "Good-bye"
break
;;
esac
done

"OUTPUT"
This program is designed to do measurement conversion
Enter yard
125468
The result in feet is:
376404
Do you want to convert from feet to yard as well?
Please enter your answer
please enter yes to continue or no to exit:
no
Enter feet?
The result in yard is:

Remove the colored read command

#! /usr/bin/ksh
echo "This program is designed to do measurement conversion"
echo "Enter yard"
read yard
echo "The result in feet is:"
expr $yard '*' 3
echo "Do you want to convert from feet to yard as well?"
echo "Please enter your answer"
echo "please enter yes to continue or no to exit:"
read
while true
do
printf "%s " " Enter feet?"
read feet
echo "The result in yard is:"
expr $feet / 3
read continue
case $continue in
[yy]*) ;;
*) printf "%s\n" "Good-bye"
break
;;
esac
done

By removing read, I defeat the purpose. I no longer have the option of asking the user what he/she wants to do. What if the user does not want to continue.

Do you mean that you want to ask user to continue or not for conversion from feet to yard at the first time? Then you should have used some variable to capture that input from the user.

#! /usr/bin/ksh
echo "This program is designed to do measurement conversion"
echo "Enter yard"
read yard
echo "The result in feet is:"
expr $yard '*' 3
echo "Do you want to convert from feet to yard as well?"
echo "Please enter your answer"
echo "please enter yes to continue or no to exit:"
read continue
while true
do
case $continue in
[yy]*) ;;
*) printf "%s\n" "Good-bye"
break
;;
esac
printf "%s " " Enter feet?"
read feet
echo "The result in yard is:"
expr $feet / 3
echo "please enter yes to continue or no to exit:"
read continue
done

I modified it to make it work. See below.

But if someone can still find a way to use th eif statement, please let me know.

#! /usr/bin/ksh
echo "This program is designed to do measurement conversion"
echo "Enter yard"
read yard
echo "The result in feet is:"
expr $yard '' 3
echo "Do you want to convert from feet to yard as well?"
echo "Please enter your answer"
echo "please enter yes only if you wish to continue:"
echo "Otherwise Press Ctrl C to exit:"read
while true
do
printf "%s " " Enter feet?"
read feet
echo "The result in yard is:"
expr $feet / 3
read continue
case $continue in
[yy]
) ;;
*) printf "%s\n" "Good-bye"
break
;;
esac
done