I need help with my big integer calculator program. The program should receive two large integers using vectors and calculate the sum, difference, product, and quotient o the two integers.

The main file is:

#include <iostream>		// cout, <<, >>
#include <fstream>		// istream, ofstream
#include <string>		// string
#include <cassert>		// assert ()
#include <vector>		// vector<T>
#include "Test5Q20.h"	// read(), add(), subtract(), multiply(), divide()

int main()
{
	cout << "Enter First Operand:  ";
	vector<double> numOperand1;
	cin >> numOperand1;					// place first number in vector num1
	cout << "Enter Second Operand:  ";
	vector<double> numOperand2;
	cin >> num2;					// place second number in vector num2

	add(vector<double> numOperand1, vector<double> numOperand2);	// determine the sum of the two operands 
	cout << "The sum of operand1 and operand2 is: " << sum << "\n";

	subtract(vector<double> numOperand1, vector<double> numOperand2);	// determine the difference of the two operands 
	cout << "The difference of operand1 and operand2 is: " << sum << "\n";

	multiply(vector<double> numOperand1, vector<double> numOperand2);	// determine the sum of the two operands 
	cout << "The product of operand1 and operand2 is: " << sum << "\n";

	divide(vector<double> numOperand1, vector<double> numOperand2);	// determine the quotient of the two operands 
	cout << "The quotient of operand1 and operand2 is: " << sum << "\n";
}

The header file is:

#include <iostream>		// istream, ostream
#include <vector>		// vector
#include <cmath>		// pow
using namespace std; 

/*add() finds the sum of operand1 and operand2.
 *
 * Receive:      numOperand1 & numOperand2, a vector<double>
 * Precondition: numOperand1 & numOperand2 is not empty
 * Return:       the sum of the operand1 & operand2
 ***************************************************************/
 
double add(vector<double>& numOperand1, vector<double>& numoperand2)
{
   if (numOperand1.empty()) || (numOperand2.empty());
   {
      cerr << "\n***ADD: empty vector received!\n" << endl;
      return 0.0;
   }
   else
         return add(numOperand1 + numOperand2);
}

/*subtract() finds the difference of operand1 and operand2.
 *
 * Receive:      numOperand1 & numOperand2, a vector<double>
 * Precondition: numOperand1 & numOperand2 is not empty
 * Return:       the difference of the operand1 & operand2
 ***************************************************************/
 
double subtact(vector<double>& numOperand1, vector<double>& numoperand2)
{
   if (numOperand1.empty()) || (numOperand2.empty());
   {
      cerr << "\n***SUBTRACT: empty vector received!\n" << endl;
      return 0.0;
   }
   else
         return add(numOperand1 - numOperand2);
}

/*multiply() finds the sum of operand1 and operand2.
 *
 * Receive:      numOperand1 & numOperand2, a vector<double>
 * Precondition: numOperand1 & numOperand2 is not empty
 * Return:       the product of the operand1 & operand2
 ***************************************************************/
 
double multiply(vector<double>& numOperand1, vector<double>& numoperand2)
{
   if (numOperand1.empty()) || (numOperand2.empty());
   {
      cerr << "\n***MULTIPLY: empty vector received!\n" << endl;
      return 0.0;
   }
   else
         return multiply(numOperand1 * numOperand2);
}

/*divide() finds the sum of operand1 and operand2.
 *
 * Receive:      numOperand1 & numOperand2, a vector<double>
 * Precondition: numOperand1 & numOperand2 is not empty
 * Return:       the quotient of the operand1 & operand2
 ***************************************************************/
 
double divide(vector<double>& numOperand1, vector<double>& numoperand2)
{
   if (numOperand1.empty()) || (numOperand2.empty());
   {
      cerr << "\n***DIVIDE: empty vector received!\n" << endl;
      return 0.0;
   }
   else
         return quotient(numOperand1 / numOperand2);
}

I need help with my big integer calculator program.

Okay.

The program should receive two large integers using vectors and calculate the sum, difference, product, and quotient o the two integers.

Okay.

The main file is:

Okay.

The header file is:

Okay.

What do you want?

Wow Pow,
You have made many errors in your header file.

1. Too many braces in your if conditions.
2. C++ is case sensitive.
3. If an if condition is followed by a semi-colon, then the if condition terminates at the semi-colon, hence the else is illegal because it follows a scoped code block, not an if block.
3. Vector does not overload the mathematical operators (+, -, *, /)
4. You have not declared any operators to actually handle the addition of the values in the vectors (you will need to iterate through the vectors in the else clause).

Try and resolve these errors, they should be raised by compiler errors when you compile. And think about how you will add the values in the vector and what you will return from the function.

Hm I need to solve the same task can someone help us more about this code?

Please check the date that this thread was created...

I was using a nice vertual bigcalc for years on xp
and using decimal remainders as part of my research
of large integer divsion and their remainders.
Is there anything out their now for win. 8.1 that
show these large decimal remainders?
At least one memory button also.

Dan

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.