Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7710509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:08:36+00:00 2026-06-01T01:08:36+00:00

i have been looking for a tutorial for a scientific calculator one the web

  • 0

i have been looking for a tutorial for a scientific calculator one the web but i could not find anything. my aim is to learn how to write a calculator app similar to the one in iPhone. does any know of any tutorials that can help me learn how to add scientific functions to a calculator app. keep in mind that i have tried the various versions of the basic calculator and have been through a few of those tutorials and just want to learn and may use the methods to add scientific functions such as rad, sin, cos and some other stuff in the app. i will be great full for any help i can get.

AP

Edit:

since there are no real material on how to build a scientific calculator out there( at least i haven’t found anything specific yet) here is the run down of how to build one.

first create a NSObject class to hold your operation methods. ( this is optional, you can set it on top of your getter (.m) file if you like.) call it whatever you want. then declare the following the the header file.

{
double operand; 
double savedNumber;
NSString *waitingOperation; 
double waitingOperand;
}

- (void)setOperand:(double)aDouble; 
- (double)performOperation:(NSString *)operation;
- (void)performWaitingOperation;

@end

then in the .m file of your NSObject class declare the methods that operates your functions. something like the following:

-(void)setOperand:(double)num
{
operand=num;
}
-(double)performOperation:(NSString *)operation
{
if([operation isEqual:@"sqrt"]){
    operand = sqrt(operand);
}else if ([operation isEqual:@"1/x"]){
    if(operand)
        operand = 1 / operand;
}else if ([operation isEqual:@"2/x"]){
    if(operand)
        operand = 2 / operand;
}else if ([operation isEqual:@"3/x"]){
    if(operand)
        operand = 3 / operand;
}else if ([operation isEqual:@"+/-"]){
    if(operand)
        operand = (-1) * operand;
}else if ([operation isEqual:@"sin"]){
    operand = sin(operand);
}else if ([operation isEqual:@"sinh"]){//you can add more scientific functions in the same way to this list.
    operand = sinh(operand);
}else if ([operation isEqual:@"cos"]){
    operand = cos(operand);
}else if ([operation isEqual:@"cosh"]){
    operand = cosh(operand);
}else if ([operation isEqual:@"tan"]){
    operand = tan(operand);
}else if ([operation isEqual:@"tanh"]){
    operand = tanh(operand);
}else if ([operation isEqual:@"M"]){
    savedNumber = operand;
}else if ([operation isEqual:@"M+"] ){
    savedNumber += operand;
}else if ([operation isEqual:@"M-"] ){
    savedNumber -= operand;
}else if ([operation isEqual:@"Recall"]){
    [self setOperand:savedNumber];
}else if ([operation isEqual:@"C"]){
    savedNumber = 0; 
    operand = 0;
    waitingOperand = 0;
    savedNumber= 0; 
}else {
    [self performWaitingOperation];
    waitingOperation = operation;       
    waitingOperand = operand;
}
return operand;
    }
    - (void) performWaitingOperation
    {
if([@"+" isEqual:waitingOperation]){
    operand = waitingOperand + operand ;
} else if([@"-" isEqual:waitingOperation]){
    operand = waitingOperand - operand ;
}else if([@"X" isEqual:waitingOperation]){
    operand = waitingOperand * operand ;
}else if([@"/" isEqual:waitingOperation]){
    if(operand)
        operand = waitingOperand / operand ;
}
    }

now in the view controller that you are trying to display the calculator you need to access all of these functions and display them in your outlets, such as buttons and text field and so on. here is the .h file

IBOutlet UILabel *display;
SCalcAI *ai;
BOOL userIsInTheMiddleOfTypingNumber;
}

- (IBAction) digitPressed: (UIButton *)sender;
- (IBAction) operationPressed: (UIButton *) sender;

rememebr to import your NSObject class header on top of this file otherwise you get an error. then in the .m file you need to declare these functions.

-(NameofyourNSOBjectClass *) ai
{
 if(!ai)
 {
ai = [[SCalcAI alloc]  init];
}
return ai;
    }

    - (IBAction) digitPressed: (UIButton *)sender
    {

 NSString *digit = [[sender titleLabel] text];
    if(userIsInTheMiddleOfTypingNumber){
        [display setText:[[display text] stringByAppendingString:digit]];
    } else{
        [display setText:digit];
        userIsInTheMiddleOfTypingNumber = YES;
    }

}
- (IBAction) operationPressed: (UIButton *) sender
{
    if(userIsInTheMiddleOfTypingNumber){
        [[self ai] setOperand:[[display text] doubleValue]];
        userIsInTheMiddleOfTypingNumber = NO;
    }
    NSString *operation = [[sender titleLabel] text];
    double result = [[self ai] performOperation:operation]; 
    [display setText:[NSString stringWithFormat:@"%g", result]];
}

then hook up all the buttons to the operations they need to be connected in the storyboard or xib. thats that. the above is the skeleton version of the whole thing but I’m sure you can build on that. if you need help send me message.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:08:37+00:00Added an answer on June 1, 2026 at 1:08 am

    The Standford iOS programming class cs193p has an example of building a simple calculator. Might be a good place to start. Great course, great videos. Paul Hagarty is a very good instructor. The scientific functions would not be hard to add once you have the core done.

    Two resources:
    http://www.tusharsharma.in/project/open-source/mathematical-calculator-iphone4/

    http://emplementation.blogspot.com/2010/11/ios-development-tutorials-on-itune-u.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been looking in to doing some test driven development for one of
Does anyone have a good State Manager tutorial in Java? I have been looking
I have been looking for a tutorial that shows or explains how to display
I have been looking for a tutorial on using LDAP on an iOS device
Right guys, I have been looking all over the internet for a tutorial to
I have been looking through the Java Tutorials at the Interfaces tutorial, specifically on
I have been looking for weeks for an OBJ-C based tutorial on how to
I've been looking through the tutorial : http://www.vogella.de/articles/AndroidSQLite/article.html and SQLite seems to have all
I've been looking and I've seen a few how-tos but I find them to
I have been looking for a tutorial to help me integrate PHPUnit with CakePHP.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.