Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

HugeInteger Class Create a class HugeInteger that uses a 40-element array of digits to store integers as large as 40 digits each. Provide friends member

HugeInteger Class

Create a class HugeInteger that uses a 40-element array of digits to store integers as large as 40 digits each.

Provide friends member functions input, output, add, subtract, multiply, divide and reminder.

For comparing HugeInteger objects, provide functions isEqualTo, isNotEqualTo, isGreaterThan, isLessThan, isGreaterThanOrEqualTo and isLessThanOrEqualToeach of these is a predicate function that simply returns true if the relationship holds between the two HugeIntegers and returns false if the relationship does not hold. Also, provide a predicate function isZero.

Overload input, output, arithmetic, equality and relational operators so that you can write expressions containing HugeInteger objects, rather than explicitly calling member functions.

Add comments (preconditions, postconditions, and purpose for each function) as needed to make your code understandable. Run a sample output. It is always a great idea to have a sample output with default values in the driver cpp file and a menu to have the user selects the operator to be checked. Paste your code and your sample outputs into a word document or a pdf. And upload. Remember, validate your entry whenever there is a users entry.

This is a sample driver cpp file

// HugeInt test program. #include #include "Hugeint.h" using namespace std; int main() { HugeInt n1{7654321}; HugeInt n2{7891234}; HugeInt n3{"99999999999999999999999999999"}; HugeInt n4{"1"}; HugeInt n5{"12341234"}; HugeInt n6{"7888"}; HugeInt result; cout << "n1 is " << n1 << " n2 is " << n2 << " n3 is " << n3 << " n4 is " << n4 << " n5 is " << n5 << " n6 is " << n6 << " result is " << result << " "; //test the non member arithmetic function //Include your test with an output // test relational and equality operators if (n1 == n2) { cout << "n1 equals n2" << endl; } if (n1 != n2) { cout << "n1 is not equal to n2" << endl; } if (n1 < n2) { cout << "n1 is less than n2" << endl; } if (n1 <= n2) { cout << "n1 is less than or equal to n2" << endl; } if (n1 > n2) { cout << "n1 is greater than n2" << endl; } if (n1 >= n2) { cout << "n1 is greater than or equal to n2" << endl; } result = n1 + n2; cout << n1 << " + " << n2 << " = " << result << " "; cout << n3 << " + " << n4 << " = " << (n3 + n4) << " "; result = n1 + 9; cout << n1 << " + " << 9 << " = " << result << endl; result = n2 + "10000"; cout << n2 << " + " << "10000" << " = " << result << endl; result = n5 * n6; cout << n5 << " * " << n6 << " = " << result << endl; result = n5 - n6; cout << n5 << " - " << n6 << " = " << result << endl; result = n5 / n6; cout << n5 << " / " << n6 << " = " << result << endl; /*write an arithmetic expression that involves multiple operations on different objects at once and output the result*/ }// HugeInt test program. #include #include "Hugeint.h" using namespace std; int main() { HugeInt n1{7654321}; HugeInt n2{7891234}; HugeInt n3{"99999999999999999999999999999"}; HugeInt n4{"1"}; HugeInt n5{"12341234"}; HugeInt n6{"7888"}; HugeInt result; cout << "n1 is " << n1 << " n2 is " << n2 << " n3 is " << n3 << " n4 is " << n4 << " n5 is " << n5 << " n6 is " << n6 << " result is " << result << " "; //test the non member arithmetic function //Include your test with an output // test relational and equality operators if (n1 == n2) { cout << "n1 equals n2" << endl; } if (n1 != n2) { cout << "n1 is not equal to n2" << endl; } if (n1 < n2) { cout << "n1 is less than n2" << endl; } if (n1 <= n2) { cout << "n1 is less than or equal to n2" << endl; } if (n1 > n2) { cout << "n1 is greater than n2" << endl; } if (n1 >= n2) { cout << "n1 is greater than or equal to n2" << endl; } result = n1 + n2; cout << n1 << " + " << n2 << " = " << result << " "; cout << n3 << " + " << n4 << " = " << (n3 + n4) << " "; result = n1 + 9; cout << n1 << " + " << 9 << " = " << result << endl; result = n2 + "10000"; cout << n2 << " + " << "10000" << " = " << result << endl; result = n5 * n6; cout << n5 << " * " << n6 << " = " << result << endl; result = n5 - n6; cout << n5 << " - " << n6 << " = " << result << endl; result = n5 / n6; cout << n5 << " / " << n6 << " = " << result << endl; /*write an arithmetic expression that involves multiple operations on different objects at once and output the result*/ }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

More Books

Students also viewed these Databases questions