the issue seems to be in the -(void) divide method. for some reason when a div by zero error handling occurs, and the value of accumulator is set to 'NAN' - it causes an issue with the final 'if else' statement in the main program.

with the condition I've put in that final if statement ([deskCalc accumulator] == NAN) - it's basically not recognising the NAN condition and is dropping through to the else statement and doing an NSLog of the accumulator ( which it frustratingly prints out as 'nan' ).

I've tried to test the rest of the program by changing it so that if there is a div by zero it's sets the value of accumulator to 999.99 for example, and then also testing for that condition, which works fine ( it NSLog's the "end" text instead of returning the accumulator ). So I know that the issue is with testing the NAN condition.

My code is below, and would really appreciate some assistance

Code: (Objective-C)

// Program to evaluate simple expressions of the form// number operator number// Implement a Calculator class

I went a different way with this. I added a bool for the Unknown Operator, and then an if-else for the displaying of the accumulator. It checks for the bool, and we know what value2 is as it's being entered by the user, if bool != YES and value2 != 0, it will print out the accumulator.

I went a different way with this. I added a bool for the Unknown Operator, and then an if-else for the displaying of the accumulator. It checks for the bool, and we know what value2 is as it's being entered by the user, if bool != YES and value2 != 0, it will print out the accumulator.

My solution was almost identical, but instead of the bool I just set operator to '?'