Question: I need help getting my code to work.. I am building a bigInteger class in C++. I have everything lined up, but the program is

I need help getting my code to work.. I am building a bigInteger class in C++. I have everything lined up, but the program is not outputting the correct answers. My teacher said this about my code. I need help getting my code to work.. I am building a

This is the requirement. bigInteger class in C++. I have everything lined up, but the program

This is the code I have

#include #include #include

using namespace std;

int valueOf(char c) { if ((c >= '0') && (c

vector toDigits(string a) { vector result(a.length()); for (unsigned int i = 0; i

void displayDecimalDigits(vector a) { for (unsigned int i = 0; i

vector addLeadingZeros(vector v, int b) { for (int i = 0; i

vector trimLeadingZeros(vector v) { int count = 0; for (unsigned int i = 0; i result(v.size() - count); for (unsigned int i = count, r = 0; i

vector normalize(vector v, int b) { vector result = v; result = addLeadingZeros(result, 1); for (int i = result.size() - 1; i >= 0; --i) { while (result[i] >= b) { result[i] -= b; result[i - 1] += 1; } } trimLeadingZeros(v); return result; } int main() { string s1 = "001238042"; vector b1 = toDigits(s1); displayDecimalDigits(b1); b1 = trimLeadingZeros(b1); displayDecimalDigits(b1); b1 = addLeadingZeros(b1, 4); displayDecimalDigits(b1); }

Cout is your friend here. For each of your functions, add cout statements at the top to output what the function received, and just before the return to display what it has computed. You may find that one of your functions is not doing quite what you want it to do. Over the course of the semester we will develop a BigInteger class with which we can perform integer operations on arbitrary-length integers. To start off, all we will do is implement a data structure to contain a BigInteger and add them. Submit a program that prompts the user for two BigIntegers, then displays their sum. Sample run (user input in bold): Welcome to BigInteger Version 1! Please enter a BigInteger: 123456789000000000000009 Please enter a BigInteger: 1 The sum is: 123456789000000000000010 Thank you for playing BigInteger! Cout is your friend here. For each of your functions, add cout statements at the top to output what the function received, and just before the return to display what it has computed. You may find that one of your functions is not doing quite what you want it to do. Over the course of the semester we will develop a BigInteger class with which we can perform integer operations on arbitrary-length integers. To start off, all we will do is implement a data structure to contain a BigInteger and add them. Submit a program that prompts the user for two BigIntegers, then displays their sum. Sample run (user input in bold): Welcome to BigInteger Version 1! Please enter a BigInteger: 123456789000000000000009 Please enter a BigInteger: 1 The sum is: 123456789000000000000010 Thank you for playing BigInteger

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!