The command to create a new account is
useradd.
No need to check if the user exists already;
useradd will do that for you and exit with an exit value of 4 if that is the case (
see man page).
useradd also has options to set the password and parts of the password policy, e.g. the -p option. Otherwise, you can for example use
passwd --stdin to provide the password from standard input.