Use Build, Rebuild All to try to compile the program. If there are any syntax errors, they should appear in a window at the bottom. Starting at the top of the list of errors, double click on each to bring up the line where the error occurred. Fix any syntax errors that were found. Keep rebuilding the program until no syntax errors remain.
Syntax errors are the easy stuff.
Now let's see if the program works correctly. Read the comments at the top of the program to see what it is expected to do. Then run it and see if it does indeed do this. Use the debugger to step over the lines of code in the main function to try to get an idea of where the error is occurring. Watch the values of the variables to see whether they are reasonable.