Code:
-(IBAction)calculate:(id)sender {
float m = ([variableM.text floatValue]);
float x = ([variableX.text floatValue]);
float y = ([variableY.text floatValue]);
float a = m*x;
float b = a+y;
//////////ERROR BEGINS HERE//////////
if (float b > 0) {
positive.hidden = YES;
}
else {
positive.hidden = NO;
}
//////////ERROR ENDS HERE//////////
answerB.text = [[NSString alloc] initWithFormat:@"%2.f", b];
answerM.text = [[NSString alloc] initWithFormat:@"%2.f", a];
}
I have no idea what's wrong with the code. 10 points for best answer!
Copyright © 2024 Q2A.ES - All rights reserved.
Answers & Comments
Verified answer
Looks like you're trying to declare 'b' again in your 'if' statement. Try removing the 'float' from if (float b>0)