0

Write a C++ program that implements an ADT class named Int50 for manipulating integer numbers with up to 50 digits. The operators provided on this type must include: sum (+), difference (-), product (*), division (/) {dropping the remainder}, output (<<), and input (>>) of values for Int50 objects. Each number will be represented by an array of short int elements, each representing one decimal digit of the whole number. Allow for positive and negative values. The input (>>) operation must allow values formatted like 0, 247, -86, and +244 to be entered but for any number of digits up to 50. On output, do not print leading zeroes. Do not prompt the user for input in the ADT, that should only be done in the application code that uses the ADT class. Use the class in a program that gives the user the ability to enter data and perform each of the calculations. The operator overloading you provide must support expressions like:

N3 = N1+N2; //each variable is of type Int50

cout << "results: " << N4 << " & " << N5 << endl; // {might print -- results: -2738 & 74682354970035}

Bonus credit will be given for properly "throwing" an "exception" for division by zero and for overflow (number entered or produced exceeds 50 digits).

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by arkoenig
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.