Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can someone help me debug this? I keep getting these issues heres my code. I\'m

ID: 668699 • Letter: C

Question

Can someone help me debug this? I keep getting these issues heres my code. I'm using xCode Objective c and buidling a basic calucltor. In your answer if you could add pi, cos, and sin I would really appreciate it. I also included the errors im getting.

ViewController.H’

#import <UIKit/UIKit.h>

#import "NSObject+CalculatorBrain.h"

@interface ViewController : UIViewController {

  IBOutlet UILabel *display;

  CalculatorBrain *brain;

  BOOL userIsInTheMiddleOfTypingANumber;

  

}

@end

—————

NSObject+CalculatorBrian.h

#import <Foundation/Foundation.h>

@interface CalculatorBrain : NSObject {

  double operand;

  NSString *waitingOperation;

  double waitingOperand;

}

-(void)setOperand:(double)adDouble;

-(double)performOperation:(NSString *)operation;

@end

———————
NSObject+CalculationBrain.m

#import <UIKit/UIKit.h>

#import "NSObject+CalculatorBrain.h"

@interface CalculatorViewController : UIViewController {

  IBOutlet UILabel *display;

  CalculatorBrain *brain;

}

-IBAction digitPressed:(UIButton *)sender;

{

  NSString *digit = [[sender titleLabel] text];

  if (userIsInTheMiddleOfTypingANumber)

  {

  [display setText:[[display text] stringByAppendingString:digit]];

  }

  else

  {

  [display setText:digit];

  userIsInTheMiddleOfTypingANumber = YES;

  }

}

-IBAction operationPressed:(UIButton *)sender;

{

  if (userIsInTheMiddleofTypingAnumber) {

  [[[self brain] setOperand:[display text] doubleValue]];

  userIsInTheMiddleofTypingANumber = NO;

  }

  NSString *operation = [[sender titleLabel]text];

  double result = [[self brain] performOperation:operation];

  [display setText:[NSString stringWithFormat:@"%g", result]];

}

@end

@implementation NSObject (CalculatorBrain)

- (CalculatorBrain *)brain

{

  if (!brain) brain = [[CalculatorBrain alloc] init];

  return brain;

}

- (void)setOperand:(double)aDouble;

{

  operand = aDouble;

}

- (void)performWaitingOperation

{

  if ([@"+" isEqual:waitingOperation])

  {

  operand = waitingOperand + operand;

  }

  else if ([@"*" isEqual:waitingOperation]);

  {

  operand = waitingOperand * operand;

  }

  else if ([@"-" isEqual:waitingOperation])

  {

  operand = waitingOperand - operand;

  }

  else if ([@"/" isEqual:waitingOperation])

  {

  if (operand) {

  operand = waitingOperand / operand;

  }

  }

}

- (double)performOperation:(NSString *)operation;

{

  if ([operation isEqual:@"sqrt"])

  {

  operand = sqrt(operand);

  }

  else if ([@"+/-" isEqual:operation])

  {

  operand = - operand;

  }   }

  else

  {

  [self performWaitingOperation];

  waitingOperation = operation;

  waitingOperand = operand;

  }

   return operand;

}

@end

———————
ViewController.m

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (IBAction)digitPressed:(UIButton*)sender

{

  NSString *digit = [[sender titleLabel] text];

  if (userIsInTheMiddleOfTypingANumber)

  {

  [display setText:[[display text] stringByAppendingString:digit]];

  }

  else

  {

  [display setText:digit];

  userIsInTheMiddleOfTypingANumber = YES;

  }

}

{

  if (userIsInTheMiddleOfTypingANumber){

  [[self brain] setOperand:[[display text] doubleValue]];

  userIsInTheMiddleOfTypingANumber = NO;

  }

  NSString *operation = [[sender titleLabel] text];

  double result = [[self brain] perfromOperation:operation];

  [display setText:[NSString stringWIthFormat:@"%g", result]];

}

- (IBAction)operationPressed:(UIButton*)sender

{

}

@end

Calculator 3 3 issues 9 ng NSObject-CalculatorBrain.m O Parse issue Parse Issu Expected'' after method prototype Parse issue Missing '@end' TO ViewController. m 9 Parse Issue Expected identifier or

Explanation / Answer

me debug this? i keep getting ...
Time remaining to decide to answer/skip : 9:45
Question in Computer Science
Can someone help me debug this? I keep getting these issues heres my code. I'm using xCode Objective c and buidling a basic calucltor. In your answer if you could add pi, cos, and sin I would really appreciate it. I also included the errors im getting.


ViewController.H’
#import <UIKit/UIKit.h>
#import "NSObject+CalculatorBrain.h"

@interface ViewController : UIViewController {
IBOutlet UILabel *display;
CalculatorBrain *brain;
BOOL userIsInTheMiddleOfTypingANumber;
  
}


@end
—————
NSObject+CalculatorBrian.h

#import <Foundation/Foundation.h>

@interface CalculatorBrain : NSObject {
double operand;
NSString *waitingOperation;
double waitingOperand;
}
-(void)setOperand:(double)adDouble;
-(double)performOperation:(NSString *)operation;
@end
———————
NSObject+CalculationBrain.m
#import <UIKit/UIKit.h>
#import "NSObject+CalculatorBrain.h"

@interface CalculatorViewController : UIViewController {
IBOutlet UILabel *display;
CalculatorBrain *brain;

}
-IBAction digitPressed:(UIButton *)sender;
{
NSString *digit = [[sender titleLabel] text];
if (userIsInTheMiddleOfTypingANumber)
{
[display setText:[[display text] stringByAppendingString:digit]];
}
else
{
[display setText:digit];
userIsInTheMiddleOfTypingANumber = YES;
}
}
-IBAction operationPressed:(UIButton *)sender;
{
if (userIsInTheMiddleofTypingAnumber) {
[[[self brain] setOperand:[display text] doubleValue]];
userIsInTheMiddleofTypingANumber = NO;
}
NSString *operation = [[sender titleLabel]text];
double result = [[self brain] performOperation:operation];
[display setText:[NSString stringWithFormat:@"%g", result]];
}
@end

@implementation NSObject (CalculatorBrain)

- (CalculatorBrain *)brain
{
if (!brain) brain = [[CalculatorBrain alloc] init];
return brain;
}
- (void)setOperand:(double)aDouble;
{
operand = aDouble;
}
- (void)performWaitingOperation
{
if ([@"+" isEqual:waitingOperation])
{
operand = waitingOperand + operand;
}
else if ([@"*" isEqual:waitingOperation]);
{
operand = waitingOperand * operand;
}
else if ([@"-" isEqual:waitingOperation])
{
operand = waitingOperand - operand;
}
else if ([@"/" isEqual:waitingOperation])
{
if (operand) {
operand = waitingOperand / operand;
}
}
}
- (double)performOperation:(NSString *)operation;
{
if ([operation isEqual:@"sqrt"])
{
operand = sqrt(operand);
}
else if ([@"+/-" isEqual:operation])
{
operand = - operand;
} }
else
{
[self performWaitingOperation];
waitingOperation = operation;
waitingOperand = operand;
}
return operand;
}
@end
———————
ViewController.m
#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (IBAction)digitPressed:(UIButton*)sender
{
NSString *digit = [[sender titleLabel] text];
if (userIsInTheMiddleOfTypingANumber)
{
[display setText:[[display text] stringByAppendingString:digit]];
}
else
{
[display setText:digit];
userIsInTheMiddleOfTypingANumber = YES;
}
}

{
if (userIsInTheMiddleOfTypingANumber){
[[self brain] setOperand:[[display text] doubleValue]];
userIsInTheMiddleOfTypingANumber = NO;
}
NSString *operation = [[sender titleLabel] text];
double result = [[self brain] perfromOperation:operation];
[display setText:[NSString stringWIthFormat:@"%g", result]];
}

- (IBAction)operationPressed:(UIButton*)sender
{
}

@end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote