Senior & Expert .Net Developers Discussion Forum by Nyros Technologies

HIRE .Net Expert Developers Programmers Coders From India
Ruby on Rails PHP .Net Developers Community, Nyros Technologies, Kakinada
 
Log in  or IF not a member please REGISTER
Username:
Password:   


Keyword
Log in | Profile 

Sample Code for Temperature Conversions:

 
Post new topic   Reply to topic    Senior & Expert .Net Developers Discussion Forum by Nyros Technologies Index -> Mobile Application Development
View previous topic :: View next topic  
Author Message
Ramya sree



Joined: 12 Mar 2010
Posts: 59

PostPosted: Mon Jul 12, 2010 1:33 pm    Post subject: Sample Code for Temperature Conversions: Reply with quote

Hi to All,
You can observe from the below code, how the temperature can be converted from Celsius to Farenheit Or Vice-versa, basing on User requirement.

>To create a new project, choose view-based template, name it as "TemperatureViewController".
>Open TemperatureViewController.h file , convert it like below:

@interface TemperatureViewController : UIViewController
{
IBOutlet UITextField *temperature;
IBOutlet UILabel *farenheit;
IBOutlet UILabel *degree;
}
@property(nonatomic, retain) UITextField *temperature;
@property(nonatomic, retain) UILabel *farenheit;
@property(nonatomic, retain) UILabel *degree;

-(IBAction)farenheitToCelsius;
-(IBAction)celsiusToFarenheit;

@end

>Then,implement the methods of .h file in TemperatureViewController.m file as :
>Synthesize all the properties here.

// defining the method for converting farenheit temperature into celsius..
-(IBAction)farenheitToCelsius
{
NSString *toCelsius = [temperature text];
double ce = (5.0/9.0)*([toCelsius doubleValue]-32.0);

NSString *cels =@"Temperature in Celsius is";
farenheit.text = [NSString stringWithFormat:@"%@: %2.0f", cels, ce];
}

//code for converting celsius temperature into farenheit
-(IBAction)celsiusToFarenheit
{
NSString *toFarenheit = [temperature text];
double fa = (9.0/5.0)*([toFarenheit doubleValue]+32.0);

NSString *faren =@"Farenheit Temperature is";
farenheit.text = [NSString stringWithFormat:@"%@: %0.4f", faren, fa];

[degree setText:@"˚F"];
}

> Open .xib file for InterfaceBuilder connections..Drag-n-drop the required objects on to the view panel,
to match with the variables defined in TemperatureViewController.h file & make the required connections.

Thank You,
Ramya Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Senior & Expert .Net Developers Discussion Forum by Nyros Technologies Index -> Mobile Application Development
Page 1 of 1


 latest topics 
 Topics   Replies   Author   Views   Last Post 
No new posts How to Add Update Delete for gridview using Webservice
1 sanjay 31 Fri Sep 10, 2010 7:05 am
setty View latest post
No new posts Is there any free webhosts that support ASP.NET. ?
2 Balaji 634 Tue Sep 07, 2010 10:24 am
chrisadam View latest post
No new posts Hostings For ASP.NET 2.0 with SQL Server
2 Avash 676 Tue Sep 07, 2010 10:21 am
chrisadam View latest post
No new posts Exceptional Manger
1 suraj 51 Thu Sep 02, 2010 8:52 am
Rahul View latest post
No new posts background image for UITableView
0 kumar 55 Wed Sep 01, 2010 10:34 am
kumar View latest post
No new posts Types of Run time exceptions
1 Dheeraj 52 Wed Sep 01, 2010 8:58 am
venkat View latest post
No new posts Access Web Page content in Windows Forms without WebBrowser
3 mouli 273 Wed Sep 01, 2010 7:31 am
rajesh View latest post
No new posts Explain Interlocked Class & Daemon Thread's?
1 mukundh 76 Wed Sep 01, 2010 7:19 am
setty View latest post
No new posts Life Cycle Of Delegate
0 vinay 40 Wed Sep 01, 2010 7:14 am
vinay View latest post
No new posts Accessing methods defined in another page
1 suraj 37 Tue Aug 31, 2010 12:45 pm
Rahul View latest post




Hire an expert .Net developer / coder / programmer or development team from India now!!

Other Forums : Ruby on Rails   ::   PHP   |   Free unlimited HTML CSS templates download

Nyros Technologies   |   Kakinada City Portal   |   Developers Blog   |   About .Net Experts   |   More