Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 1 [25 points] Different variations of types int and float exist in C++ and other languages. They are usually limited by minimum and maximum

image text in transcribed

Problem 1 [25 points] Different variations of types int and float exist in C++ and other languages. They are usually limited by minimum and maximum values. Sometimes it is desired to have versions of these types with unlimited bounds. Java solves this problem by providing Biginteger and BigDecimal classes. In this problem it is required to develop a new C++ type (class) that can hold unlimited decimal integer values and performs arithmetic operations on them. You will develop in C++ a class, BigDecimallnt that supports writing statements with extremely long integer values like these: BigDecimallnt num1("123456789012345678901234567890"); BigDecimallnt num2("113456789011345678901134567890"); BigDecimallnt num3 = num2 2 num 1 ; cout "num 1= " num1 endl; cout "num 2= " num 2 endl; //236913578023691357802369135780 cout "num 2 + num 1= " num 3 endl; Your task is: (1) Design the class BigDecimallnt that has the following public interface (set of operations available to use by developers using the class): [18 points, 3 points for each function] BigDecimallnt (string decStr); // Initialize from string and rejects bad input BigDecimallnt (int decInt); // Initialize from integer BigDecimallnt operator+ (BigDecimallnt anotherDec); BigDecimallnt operator= (BigDecimallnt anotherDec); Int size(); You will also need to overwrite the operator as follows: friend ostream\& operator (ostream\& out, BigDecimallnt b) Using data encapsulation, you are free to store the digits of the big decimal integer in whatever container you like. You might store them in an array, a vector, a string or whatever. These are details that are not important to the user of your class. You will need to build + and - operations that work on the representation you chose. (2) Implement the class BigDecimallnt and write five test cases (including-ve numbers) to test it. Implement a program that runs the test cases and verifies the result. [ 7 points, 2 for each test case and 2 for the class]

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions

Question

If ( A^2 - A + I = 0 ), then inverse of matrix ( A ) is?

Answered: 1 week ago

Question

What is computer neworking ?

Answered: 1 week ago