The posted code does not validate the input to the extent that the given integer must be >= -1.
If -1 is given, the loop should end without comparing -1 to max/min. Otherwise min would always be set to -1 on the way out of the loop.
The logic in the code for max seems correct, but I am not so sure the min is.
I would think the first iteration through the loop would be special. The first iteration there is no previous min/max, and the number given would be the min and max.
So if this were my project, I would start by writing down the requirements of the project in list style. Then sort them into the order that they should be done in. For example if -1 is given, do not try to compare to max/min. So checking for -1 would be a step required to be done before comparing max/min. This ordered list will be useful in keeping the code on track. What I like to do is break the steps down into smaller steps. Then go over the list of steps again and break each step down more and more until each step seems so simple. Then as I write code I start with the first step, and get the code working to that point, and test before moving on to add code for the next step.