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

Have a homework program to do and I am completely stuck i need some help getting

ID: 3817878 • Letter: H

Question

Have a homework program to do and I am completely stuck i need some help getting started im literally pulling my hair out. Im not good with arrays and functions, I will post the full question below and then at the very bottom I will put a little bit of code that I have started. Any help and feedback is greatlyyyyyyyyy appreciated.

Write a program to perform addition and subtraction operations with large integers up to 20 digits in length. Your program shall be able to input a positive integer, an operator (+ or -), and another positive integer. It then outputs the sum or difference of the two numbers if the operation is legal. For subtraction, you can assume that the first operand is larger than or equal to the second operand unless extra credit option b is

attempted. Your program will perform the calculation by implementing the usual paper- and-pencil addition or subtraction algorithm (adding or subtracting one digit at a time with carrying or borrowing as needed). The result is stored in an int array and it is then printed to the screen.

Your program must allow the user to continue until the expression 0 % 0 is entered. The following is a sample run of the program and you must follow its user-interface.

[Some information/instructions including your name]

Enter an expression --> 1234 + 72<Enter>

1234 + 72 = 1306

Enter an expression --> 1234 - 72<Enter>

1234 - 72 = 1162

Enter an expression --> 123456789012345678901234 - 1<Enter>

Invalid operand (too large).

Enter an expression --> 123456789 – 123A5<Enter> Invalid operand (bad digit).

Enter an expression --> 77777777777777777777 + 22222222222222222222<Enter>

77777777777777777777 + 22222222222222222222 = 99999999999999999999

Enter an expression --> 99999999999999999999 + 1<Enter>

Integer overflow.

Enter an expression --> 0 % 0<Enter>

Thanks for using my program. Good bye!

My terrible at an attempt is below ( Please dont be harsh)

#include <iostream>
#include <iomanip>
using namespace std;
const int MAX = 20;
int first[MAX];
int second[MAX];
char x;
void Addition(int, int);
int Add(int, int);
int main()
{
int first[MAX];
int second[MAX];
char x;
Addition(first[MAX], second[MAX]);
int sum = Add(first[MAX], second[MAX]);
cout << sum;
return 0;
}
void Addition(int first[MAX], int second[MAX])
{
char x;
cout << " Please enter in equation " << endl;
cin >> first[MAX], x, second[MAX];
}

float Add(int first[MAX], int second[MAX])
{
  char x;
  int sum;
  if ( x = '+')
  { int sum = first[MAX] + second[MAX];
  }
  else if (x = '-')
  {
   int sum = first[MAX] - second[MAX];
  }
  return sum;
}

Explanation / Answer

Programming for additional code

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