
in c++ i need to implement the first public function and the driver code
Implement a BigNumber.cpp to go with the following BigNumber.h. Meaning of operations is the usual meaning as for ints. Upload your BigNumber.cpp along with t BigNumber.h and a driver that tests each function at least once.
For the multiplication, division and remainder operators you may use repeated addition and subtraction. You'll get up to 10 points extra credit if you implement those operations more efficiently. As a testcase for multiplication you should try 449! (That's a number with just under 1000 digits.)
For operator>> and the string constructor, just skip over characters that aren't legal (e.g. a nondigit within the number). The only nondigit that's allowed is a single minus sign in front to indicate that the number is negative.
You may modify BigNumber.h by adding prototypes for helper functions, if needed. But don't change prototypes for the functions that are already there
#ifndef BIGNUMBER_H
#define BIGNUMBER_H
#include <istream>
#include <ostream>
#include <string>
using namespace std;
class BigNumber
{
friend ostream& operator<<(ostream& out, const BigNumber& c);
friend istream& operator>>(istream& in, BigNumber& c);
public:
static const int MAXDIGITS = 1000;
private:
char digits[MAXDIGITS]; // The number may have up to MAXDIGITS digits
bool negative; // true for negative numbers and false otherwise. Always false if the number is 0.
int numDigits; // You may want to give numdigits the value 0 if the number is 0.
public:
BigNumber(int value = 0);
BigNumber(string s);
void setValue(int n);
void setValue(const string& s); // e.g. if s is "-45" then the number is -45.
int getNumDigits() const;
double toDouble() const; // Return a double that approximates the current object.
BigNumber& operator++();
BigNumber operator++(int n);
bool operator> (const BigNumber& c) const;
bool operator< (const BigNumber& c) const;
bool operator>= (const BigNumber& c) const;
bool operator<= (const BigNumber& c) const;
bool operator== (const BigNumber& c) const;
bool operator!= (const BigNumber& c) const;
BigNumber operator-() const; // unary minus (return BigNumber that's additive opposite of *this, e.g. -20 --> 20)
BigNumber& operator--();
BigNumber operator--(int n);
BigNumber& operator+=(const BigNumber& c);
BigNumber operator+(const BigNumber& c);
BigNumber& operator-=(const BigNumber& c);
BigNumber operator-(const BigNumber& c);
BigNumber& operator*=(const BigNumber& c);
BigNumber operator*(const BigNumber& c);
BigNumber& operator/=(const BigNumber& c);
BigNumber operator/(const BigNumber& c);
BigNumber& operator%=(const BigNumber& c);
BigNumber operator%(const BigNumber& c);
};
#endif

Trending nowThis is a popular solution!
Step by stepSolved in 4 steps

- tutorial. B4 Amend your code to keep track of the total number of moves in the game, by writing a function PlayHanoi2 (pos, a, b, c,n, j) which has an additional input j (which will be zero on the initial input) to serve as a move-counter, and which outputs suitably modified (pos, j). Define a function WholeGame2 (n) which runs PlayHanoi2 on a suitable starting configuration. This might be tricky depending on how you coded B3: the danger is that the counting variable j will assume different val- ues in different subroutines. Make sure you keep careful track of the current game position and number of moves throughout your function.arrow_forwarddef double(num): num = float(num) return num * 2 double(5.0) I passed 5/6 cases. However, I don't know how to fix the Missing function_call error. Can you please help me?arrow_forwardAdd 3 parameters to each function in the code below. ********************************************* Code starts here ************************************************** Module.py #Defination to sort the list def sort(listNum): sortedList = [] #While loop will run until the listNum don't get null while(len(listNum) != 0 ): #Set the min as first element in list min = listNum[0] #iterate over the list to compare every element with num for ele in listNum: #If element is less than min if ele < min: #Then set min as element min = ele #append the sorted element in list sortedList.append(min) #Remove the sorted element from the list listNum.remove(min) return sortedList #Function to find the sum of all elements in list def SumOfList(listNum): #Set the sum as zero sum =0 #Iterate over the list to get every element for ele in…arrow_forward
- I have seen some solutions to this problem in Bartleby's library that make no sense to me. I am learning C++, more specifically working with dynamic integers and have become confused with what has been provided previously by others. Using dynamic integers, can I get help with creating a class named 'largeIntegers' so that an object of this class can store an integer of any number of digits. If I could get help with setting up operations to add, subtract, multiply, and compare integers stored in two objects. Also, if someone could explain and help myself create constructors to properly initialize objects and functions to set, retrieve, and print the values of objects. There are three files I am working with: main.cpp, largeIntegers.h, and largeIntegers.cpp largeIntegers.cpp #include <iostream> using namespace std; largeIntegers.h //Specification file largeIntegers.h #ifndef H_largeIntegers #define H_largeIntegers #include <iostream> using namespace std;…arrow_forwardC++ question You work with emergency services in Britain and the emergency number just changed: Yikes! That’s a big change. What if the number changes again? Let’s build a function that prints out the current emergency number, whatever it is from now on. Above main(), define a voidfunction get_emergency_number()that accepts one parameter: a string with the name emergency_numberarrow_forwardComplete the function in C++.arrow_forward
- Write a function that converts a word or sentence to Pig Latin. It should be a function with one parameter of type string, that returns a value of type string. The input is English and the output is Pig Latin C++. JUST ONLY USE Pig Latin is a method of "encoding" English so that it is more difficult to understand. Children who become good at Pig Latin are able to speak to each other without other children or adults understanding what they are saying. To encode a word into Pig Latin, simply move any consonants from the beginning to the end of the word and add "ay". If the word does not begin with a consonant then simply append "way". If the word does not contain any vowels, append "way". For example, "boat" becomes "oatbay", "strength" becomes "engthstray", "eat" becomes "eatway", and "psst" becomes "psstway". Ifway ouyay ancay eadray isthay, ouyay understandway Igpay Atinlay!arrow_forwardDateType keeps only the integer representation of the month,day, and year. When a month is wanted in string form, the string iscalculated. An alternate approach would be to add a string field tothe date and calculate and store the string representation in theInitialize function. Which methods would have to bechanged? Would this change make the use of an if statement tofind the appropriate string more or less attractive? Write the code in C++for this if statement.arrow_forwardUsing C++ Using your own creativity, make a set of function templates that have these features: This function must return a value. A function template with 1 template parameter, T. And, any other parameters you want. A function template with 2 template parameters, T1 and T2. And, any other parameters you want Within main (): Call your template functions and demonstrate how they work. Construct objects and show off your amazing programming skills!arrow_forward
- Write a function definition called AddPoints that has one integer parameter called points & the function returns an integer. (in C). Inside the function, declare, ask, & get an integer from the user (the bonus points), add the bonus points to points thst are copied into the function & return the sum.arrow_forwardIn C/C++, Function overloading is the process of creating several functions that have exactly the same name. In order to overload successfully, each function must have: A. A different parameter list B. A different number of parameters and a different return type C. An integer on the end of the function name, such as func1()and func2() D. Either A or B E. Both A and Carrow_forwardThe C Programming Language for prime tester Take a number from the command line. Do error checking. If the number is prime, output "the number <> is prime." If it is not prime, output the factors ("the number <> has the factors <>, <>, <>, <>") 10 - proper functioning 10 - style (esp good naming and breakdown to functions)arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





