Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ - Large Integers Problem: Numerous problems, primarily dealing with mathematical recreation, involve operations on numbers with a very large number of digits far beyond

C++ - Large Integers

Problem:

Numerous problems, primarily dealing with mathematical recreation, involve operations on numbers with a very large number of digits far beyond the capability of the normal integers used by computers.

Your assignment:

Write and test an Object-Oriented C++ program to perform math operations on very large integers.

Discussion:

In C++, the largest int value is 2,147,483,647 (10 digits), and the largest long long value is 9,223,372,036,854,775,807 (19 digits). So, a value larger than these cannot be stored and processed as an integer. Similarly, if the sum or product of two positive integers is greater than either of these values, the result will be incorrect. One way to store and manipulate large integers is to store each individual digit of the value as an element of an array. Consider the following issues when developing your solution to this problem.

Define a class named LargeInt that holds one integer value with as many digits as the user needs (at least 50). Include constructor(s) and methods to manage and operate on the value. The only math operation that MUST be included is addition. Be sure to include a method that will format the value for output as a string.

Implement three objects of the LargeInt class within function main().

Input two large numbers from the user to initialize two of the LargeInt objects. Initialize the third LargeInt object to zero, and add the other two LargeInt values into it.

Display the two input values and their sum.

Repeat the process of inputting two large numbers, adding them together, and displaying the result until the user opts to quit.

Coding

Each class must be defined within its own set of .h and .cpp files.

The program must accept any valid signed integer as input. Validate all inputs and do not proceed until valid values are entered.

Format your source code according to the style guide presented in class.

Hints

Read input values as strings and store the digits of the value in an array/vector.

Store the ones digit in element 0 of the array/vector.

Remember how you were taught to do addition with pencil and paper. Use that same method here

Please show clearly where .h and .cpp files end and begin also what to name .h class when adding

Thank you in advance!

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

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

3rd Edition

0128012757, 978-0128012758

More Books

Students also viewed these Databases questions