
Untitled
By: a guest on
Jun 17th, 2012 | syntax:
None | size: 1.72 KB | hits: 12 | expires: Never
temperature converter not giving output
#import <UIKit/UIKit.h>
float n ;
float k;
@interface farh_celcius_conv_AppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
UILabel *display;
IBOutlet UITextField *farhenite;
IBOutlet UIButton *convert;
}
-(IBAction) convert;
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UILabel *display;
@property (nonatomic, retain) IBOutlet UITextField *farhenite;
@property (nonatomic, retain) IBOutlet UIButton *convert;
@end
#import "farh_celcius_conv_AppDelegate.h"
@implementation farh_celcius_conv_AppDelegate
@synthesize window,display,farhenite;
-(IBAction) convert {
NSString *str = [NSString text];
float n = [str floatValue];
k = (n - 32)*(5/9);
[display setText:[NSString stringWithFormat:@"%f",k]];
}
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after application launch
[window makeKeyAndVisible];
}
- (void)dealloc {
[window release];
[super dealloc];
}
@end
-(IBAction) convert {
NSString *str = yourTextField.text; // In your case farhenite i guess
float n = [str floatValue];
k = (n - 32)*(5/9);
[display setText:[NSString stringWithFormat:@"%f",k]];
}
NSString *str = textField.text;
NSString *str = display.text;
float n = [str floatValue];
k = (n - 32)*(5/9);
[display setText:[NSString stringWithFormat:@"%f",k]];
-(IBAction) convert {
NSString *str = farhenite.text;
float n = [str floatValue];
k = (n - 32)*(5/9);
[display setText:[NSString stringWithFormat:@"%f",k]];
}
NSString *str = display.text;