I am making an app that finds the roots of a quadratic equation. It looks like this:
ViewController.m-
//
// ViewController.m
// PercentFinder
//
// Created by Danny Flax on 6/21/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import "ViewController.h"
#import <UIKit/UIKit.h>
#import <stdio.h>
@implementation ViewController
-(IBAction)Solve(UIButton*)sender{
NSString*as=[A text];
int a=[as intValue];
NSString*bs=[B text];
int b=[bs intValue];
NSString*cs=[C text];
int c=[cs intValue];
int d=((-1*b)+sqrt((b*b)-4*(a*c)))/(2*a);
int e=((-1*b)-sqrt((b*b)-4*(a*c)))/(2*a);
[Answer setText:[NSString stringWithFormat
"%d and %d", d,e]];
}
@end
For some odd reason, it returns 0 for the values of d and e no matter what I type. I'm just a beginner, so there probably is some obvious problem that I missed, and I would greatly appreciate it if somebody could help me.
ViewController.m-
//
// ViewController.m
// PercentFinder
//
// Created by Danny Flax on 6/21/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import "ViewController.h"
#import <UIKit/UIKit.h>
#import <stdio.h>
@implementation ViewController
-(IBAction)Solve(UIButton*)sender{
NSString*as=[A text];
int a=[as intValue];
NSString*bs=[B text];
int b=[bs intValue];
NSString*cs=[C text];
int c=[cs intValue];
int d=((-1*b)+sqrt((b*b)-4*(a*c)))/(2*a);
int e=((-1*b)-sqrt((b*b)-4*(a*c)))/(2*a);
[Answer setText:[NSString stringWithFormat
}
@end
For some odd reason, it returns 0 for the values of d and e no matter what I type. I'm just a beginner, so there probably is some obvious problem that I missed, and I would greatly appreciate it if somebody could help me.