If you configure sudo correctly, you don't need to type the password.
You can use visudo to edit sudoers file which manages sudo stuff.
You should put a lines like this using visudo:
Code:
%users localhost = NOPASSWD: /sbin/halt
%users localhost = NOPASSWD: /sbin/reboot
That will allow any user inside the users group to execute sudo /sbin/halt and sudo /sbin/reboot without typing root's password.
Instead of %users (the % refers to a group) you can use directly the user name.
Edit: Now that this refreshed, basically what keefaz suggested :P