Hello everyone.
I am new to Xcode. However, I used to code for visual basic before and I wonder if that will help me to get along with iPhone development.
I am trying to create an app that is related to mathematics, but I'm stuck and I need some help in coding.
So here is the main view of the application
I want the user to insert values for A, B, and C. Then, when the button 'Solve' is tapped, the two values for X1 and X2 will be calculated.
So here is my .h file where I specified the textfields and labels
And my problem now is in the .m file where I have to insert the code that will solve for the values of X. In visual basic, this was pretty easy, but here I am a bit confused.
I want the button 'Solve' to do the following:
Oh, and (if possible) I want a pop-up message that will ask the user to fill in all the textfields in case one of them is left empty. I think I know the code for the pop-up message, but I don't know where to place it.
Anyone can help me with this?
Thanks
I am new to Xcode. However, I used to code for visual basic before and I wonder if that will help me to get along with iPhone development.
I am trying to create an app that is related to mathematics, but I'm stuck and I need some help in coding.
So here is the main view of the application

I want the user to insert values for A, B, and C. Then, when the button 'Solve' is tapped, the two values for X1 and X2 will be calculated.
So here is my .h file where I specified the textfields and labels
Code:
#import <UIKit/UIKit.h>
@interface SecondViewController : UIViewController {
IBOutlet UILabel *label1;
IBOutlet UILabel *label2;
IBOutlet UITextField *valueA;
IBOutlet UITextField *valueB;
IBOutlet UITextField *valueC;
}
-(IBAction)solve;
@end
And my problem now is in the .m file where I have to insert the code that will solve for the values of X. In visual basic, this was pretty easy, but here I am a bit confused.
I want the button 'Solve' to do the following:
Code:
label1 = ( -(valueB) + ( (valueB)^2 - (4*valueA*valueC) )^0.5 ) / (2*valueA)
label2 = ( -(valueB) - ( (valueB)^2 - (4*valueA*valueC) )^0.5 ) / (2*valueA)
Code:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error!" message:@"You must fill in all the textfields" delegate:self cancelButtonTitle:@"Ok" , nil];
Anyone can help me with this?
Thanks
Last edited: