Question: FOR C++ Help PLEEASE BigNumber class Implement a BigNumber class that stores nonnegative integers with up to 1000 digits. The digits will be stored as

FOR C++ Help PLEEASE

BigNumber class

Implement a BigNumber class that stores nonnegative integers with up to 1000 digits. The digits will be stored as array elements in reverse order, e.g. 234 is stored with 4 stored in location zero, 3 stored in location 1 and 2 stored in location 2 . This approach is required, not optional.

You will implement the BigNumber.cpp file to go with the BigNumber.h below. You'll also want to implement a driver.cpp to test all member functions. For example ... BigNumber n(234); cout << n << endl; (etc.) // insert tests for all the operations ___________________________________________________

Your implementation for multiplication should be efficient enough to compute factorials using a function similar to the one below.

You should be able to compute factorial(100) without much time delay.

BigNumber factorial(const BigNumber & num) {

BigNumber temp(1), num2(num);

while (num2 > 1) {

temp *= num2--; }

return temp; }

#ifndef BIGNUMBER_H

#define BIGNUMBER_H

#include

using namespace std;

class BigNumber {

friend ostream &operator<<(ostream &, const BigNumber &); // stream insertion operator: output digits in correct order. Don't add endl

friend istream &operator>>(istream &, BigNumber &); // stream extraction operator IGNORE NON DIGITS

private:

int digits[1000]; // Note: digits[i] represents the 10^i's place digit.

int numDigits; // number of digits starting from leading nonzero digit. // (This means zero has numDigits equal to 0.)

public:

BigNumber(int value = 0); // default constructor and int constructor.

BigNumber(string value); // string constructor. IGNORE NON DIGITS

int getNumDigits() const; // return numDigits

bool isZero() const; // return true iff *this is equal to ZERO

bool operator< (const BigNumber & c) const; // less than

bool operator> (const BigNumber & c) const; // greater than

bool operator>= (const BigNumber & c) const; // greater than or equal

bool operator<= (const BigNumber & c) const; // less than or equal

bool operator== (const BigNumber & c) const; // equal

bool operator!= (const BigNumber & c) const; // not equal

BigNumber & operator++ (); // preincrement

BigNumber operator++ (int dummy) ; // postincrement

BigNumber operator+ (const BigNumber & c ) const ; // plus

BigNumber& operator+= (const BigNumber & c ); // plus equals

BigNumber operator* (const BigNumber & c ) const ; // times

BigNumber& operator*= (const BigNumber & c ); // times equals

}; #endif

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!