IN c++ See the specification of the HugeInt class. Complete the implementation of this class. Provide a driver to demonstrate the features of the HugeInt class.

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++ See the specification of the HugeInt class.
Complete the implementation of this class.
Provide a driver to demonstrate the features of the HugeInt class.

HugeInt.h

#ifndef HUGEINT_H_
#define HUGEINT_H_

enum SignType {PLUS, MINUS};

class HugeInt{
private:
   struct Node
   {
       int digit; // SINGLE DIGIT ONLY ie: (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
       Node *next; // Next More Significant Digit
   };              
  
   /* Integer 345 is stored in List: 3 <- 4 <- 5 <- digits
       Integer 123 is stored in List: 1 <- 2 <- 3 <- digits
       To add: add the least significant digits, potentially
       keeping track of a carry value. Then move to the next
       left nodes in both HugeInts. Add these and the carry.
       Create a new carry value. Continue until both HugeInt
       lists are empty. If one list is empty, keep processing
       the non-empty list.
   */

   Node *digits;    //Linked list of digit nodes
   SignType sign;    //enum of the sign of the HugeInt
   int numDigits;    //Number of digits in the HugeInt
   void makeEmpty(); //clear the linked list of digits
public:
   HugeInt();
   ~HugeInt();
   bool operator<(HugeInt second);//compare for less than. return true/false
   bool operator==(HugeInt second);//compare for equal. return true/false
   HugeInt operator+(HugeInt second);//add
   HugeInt operator-(HugeInt second);//subtract
   HugeInt operator*(HugeInt second);//multiply
   HugeInt operator/(HugeInt second);//divide
   void insertDigits(int); //insert integer number. Insert each digit separately!!!!!!!
   void write(ofstream&); //Write the digits to a file. Pass ofstream as arg
};

#endif

HugeInt Class
The HugeInt class represents an integer of very many digits.
The digits are stored in a linked list of nodes.
Each node has a single integer digit and a pointer to the next, more significant digit.
A single pointer of type Node points to the least significant digit.
The digits are stored in order from the least significant digit to the most significant digit.
The HugeInt objects may be added, subtracted, multiplied, and divided. This must be done with operator overloading.
The Hugeint objects may be compared for equal or less than. This must be done with operator overloading.
A HugeInt Object may be written to a file using the write method.
There are two ways to implement multiplication and division. One is to use repeated addition (or subtraction); the other is to simulate how we do multiplication (and division) by hand. You may use either method.


HugeInt Driver
The HugeInt driver should create several HugeInt objects and demonstrate all features.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 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