Unsurprisingly this is a common issue in scripting and where there is a common issue there is often a standard solution, in this case the use of the getopts command.
Take a look at IBM's well worked example of how getopts is used
Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.
Please review the rules, which you agreed to when you registered, if you have not already done so.
More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.