The last sentence is a very good hint. There are man pages for files as well as programs, including "man 5 passwd" and "man 5 group".
You have obvious stated a homework question, and you can't expect people to do the problem for you. You might want to google for the "rute guide" for help getting started learning bash scripting. The "SAG Guide" on the www.tldp.org
website to learn about how linux works, including the fields of /etc/passwd, /etc/group and /etc/shadow.