I suggest you try calling your maximise function with known values and then test if you are getting the proper results.
most folks will use a framework for unit testing but in a simple case, it is better to just walk through it in a debugger or printf/cout the various intermediate results of rentPU and profit for each loop value..