Question
C++ (Huge Integer Class) Create a class Huge Integer that uses a 40-element array of digits to store integers as large as 40 digits each.
The files needed are main.cpp, HugeInteger.h, and HugeInteger.cpp
The main.cpp is provided below:
#include #include "HugeInteger.h" // include definition of class HugeInteger using namespace std;
int main() { HugeInteger n1{7654321}; // HugeInteger object n1 HugeInteger n2{"100000000000000"}; // HugeInteger object n2 HugeInteger n3; // HugeInteger object n3 HugeInteger n4{5}; // HugeInteger object n4 HugeInteger n5; // HugeInteger object n5 // outputs the sum of n1 and n2 n5 = n1.add(n2); cout
// assigns the difference of n2 and n4 to n5 then outputs n5 n5 = n2.subtract(n4); cout // checks for equality between n2 and n2 if (n2.isEqualTo(n2)) { cout }
// checks for inequality between n1 and n2 if (n1.isNotEqualTo(n2)) { cout }
// tests for greater number between n2 and n1 if (n2.isGreaterThan(n1)) { cout }
// tests for smaller number between n4 and n2 if (n4.isLessThan(n2)) { cout } // tests for smaller or equal number between n4 and n4 if (n4.isLessThanOrEqualTo(n4)) { cout }
// tests for smaller or equal number between n4 and n2 if (n4.isLessThanOrEqualTo(n2)) { cout }
// tests for greater or equal number between n3 and n3 if (n3.isGreaterThanOrEqualTo(n3)) { cout } // tests for greater or equal number between n2 and n3 if (n2.isGreaterThanOrEqualTo(n3)) { cout } // tests for zero at n3 if (n3.isZero()) { cout } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started