Log in or register to post comments

Math equations in Objecive C iOS development

February 23, 2018 - 3:24am #1

Hi all,

 

I am trying to develop a starter app just to get used to some of the utilities of Xcode and iOS development. I am trying to create an app that will solve the quadratic equation. I have tried to add this code under the "Calculate " button action. First I had "Calculate" just add the three inputs together. Now I am trying to make it solve the equation. This is what I put so far. And let me remind you I am very new to this so what I have probably looks very stupid and wrong.

-(IBAction) Calculate {

float x = ([A.text floatValue]); 

float y = ([B.text floatValue]);

float z = ([C.text floatValue]);

total.text =[NSString alloc]initWithFormat:@"%.2f", -y+sqrtf(y*y-4*x*z)/2*x;

}



I know this is not the full equation, but this is what I have so far. The error I receive is to add a bracket where the semicolon is. Does anybody know how to make this more effecient? I wanted to create a solveEquation() function but I ran into problems. Does anybody know what I can do? Any help will be appreciated!

Math equations in Objecive C iOS development

February 27, 2018 - 7:58am #2

You're missing an outer set of brackets on the last line:

total.text = [[NSString alloc] initWithFormat: @"%.2f", -y+sqrtf(y*y-4*x*z)/2*x];

But I'm also not sure what this has to do with Vuforia. You'd probably get better results posting on StackOverflow.

Log in or register to post comments