in c++ i need to implement the first public function and the driver code  Implement a BigNumber.cpp to go with the following BigNumber.h.  Meaning of operations is the usual meaning as for ints. Upload your BigNumber.cpp along with t BigNumber.h and a driver that tests each function at least once.  For the multiplication, division and remainder operators you may use repeated addition and subtraction. You'll get up to 10 points extra credit if you implement those operations more efficiently.  As a testcase for multiplication you should try 449!  (That's a number with just under 1000 digits.) For operator>> and the string constructor, just skip over characters that aren't legal (e.g. a nondigit within the number). The only nondigit that's allowed is a single minus sign in front to indicate that the number is negative. You may modify BigNumber.h by adding prototypes for helper functions, if needed. But don't change prototypes for the functions that are already there   #ifndef BIGNUMBER_H #define BIGNUMBER_H #include #include #include using namespace std; class BigNumber {     friend ostream& operator<<(ostream& out, const BigNumber& c);     friend istream& operator>>(istream& in, BigNumber& c); public: static const int MAXDIGITS = 1000; private:   char digits[MAXDIGITS];  // The number may have up to MAXDIGITS digits   bool negative;   // true for negative numbers and false otherwise. Always false if the number is 0.   int  numDigits;   // You may want to give numdigits the value 0 if the number is 0. public:     BigNumber(int value = 0);   BigNumber(string s);     void setValue(int n);   void setValue(const string& s); // e.g. if s is "-45" then the number is -45.     int getNumDigits() const;   double toDouble() const;  // Return a double that approximates the current object.     BigNumber& operator++();     BigNumber operator++(int n);   bool operator> (const BigNumber& c) const;   bool operator< (const BigNumber& c) const;     bool operator>= (const BigNumber& c) const;     bool operator<= (const BigNumber& c) const;     bool operator== (const BigNumber& c) const;     bool operator!= (const BigNumber& c) const;   BigNumber operator-() const; // unary minus (return BigNumber that's additive opposite of *this, e.g. -20 --> 20)     BigNumber& operator--();     BigNumber operator--(int n);     BigNumber& operator+=(const BigNumber& c);     BigNumber operator+(const BigNumber& c);     BigNumber& operator-=(const BigNumber& c);   BigNumber operator-(const BigNumber& c);     BigNumber& operator*=(const BigNumber& c);     BigNumber operator*(const BigNumber& c);     BigNumber& operator/=(const BigNumber& c);     BigNumber  operator/(const BigNumber& c);     BigNumber& operator%=(const BigNumber& c);     BigNumber  operator%(const BigNumber& c); }; #endif

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

in c++ i need to implement the first public function and the driver code 

Implement a BigNumber.cpp to go with the following BigNumber.h.  Meaning of operations is the usual meaning as for ints. Upload your BigNumber.cpp along with t BigNumber.h and a driver that tests each function at least once. 

For the multiplication, division and remainder operators you may use repeated addition and subtraction. You'll get up to 10 points extra credit if you implement those operations more efficiently.  As a testcase for multiplication you should try 449!  (That's a number with just under 1000 digits.)

For operator>> and the string constructor, just skip over characters that aren't legal (e.g. a nondigit within the number). The only nondigit that's allowed is a single minus sign in front to indicate that the number is negative.

You may modify BigNumber.h by adding prototypes for helper functions, if needed. But don't change prototypes for the functions that are already there

 

#ifndef BIGNUMBER_H
#define BIGNUMBER_H

#include <istream>
#include <ostream>
#include <string>

using namespace std;

class BigNumber
{
    friend ostream& operator<<(ostream& out, const BigNumber& c);

    friend istream& operator>>(istream& in, BigNumber& c);
public:
static const int MAXDIGITS = 1000;
private:
  char digits[MAXDIGITS];  // The number may have up to MAXDIGITS digits
  bool negative;   // true for negative numbers and false otherwise. Always false if the number is 0.
  int  numDigits;   // You may want to give numdigits the value 0 if the number is 0.

public:
    BigNumber(int value = 0);
  BigNumber(string s);
    void setValue(int n);
  void setValue(const string& s); // e.g. if s is "-45" then the number is -45.
    int getNumDigits() const;
  double toDouble() const;  // Return a double that approximates the current object.
    BigNumber& operator++();
    BigNumber operator++(int n);
  bool operator> (const BigNumber& c) const;
  bool operator< (const BigNumber& c) const;
    bool operator>= (const BigNumber& c) const;
    bool operator<= (const BigNumber& c) const;
    bool operator== (const BigNumber& c) const;
    bool operator!= (const BigNumber& c) const;
  BigNumber operator-() const; // unary minus (return BigNumber that's additive opposite of *this, e.g. -20 --> 20)
    BigNumber& operator--();
    BigNumber operator--(int n);
    BigNumber& operator+=(const BigNumber& c);
    BigNumber operator+(const BigNumber& c);
    BigNumber& operator-=(const BigNumber& c);
  BigNumber operator-(const BigNumber& c);
    BigNumber& operator*=(const BigNumber& c);
    BigNumber operator*(const BigNumber& c);
    BigNumber& operator/=(const BigNumber& c);
    BigNumber  operator/(const BigNumber& c);
    BigNumber& operator%=(const BigNumber& c);
    BigNumber  operator%(const BigNumber& c);
};


#endif 

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education