Here's a function I wrote for the purpose that I use in my scripts. It checks to see if the required package is installed and if not, prompts the user to install it. It requires a package name as a parameter. If you don't know the name of the package a required program belongs to you can look it up. Information on that available here.
function getreq {
dpkg-query --show "$1"
if [ "$?" = "0" ];
then
echo "$1" found
else
echo "$1" not found. Please approve installation.
sudo apt-get install "$1"
if [ "$?" = "0" ];
then echo "$1" installed successfully.
fi
fi
}