Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

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. Provide member functions input, output, add, and subtract. For comparing Huge Integer objects, provide member functions isEqualTo, isNotEqualTo, isGreaterTha, isLessTha, isGreaterThanOrEqualTo, isLessThanOrEqualTo -- each of these is a "predicate" fucntion that simply returns true if the relationship holds between the two Huge Integers and returns false if the relationship does not hold. Also provide predicate funciton is Zero.

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

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

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions