subject

Create a class HugeInteger which uses a vector of digits to store huge integers. A HugeInteger object has a sign that indicates if the represented integer is non-negative (0) or negative (1). Provide methods parse, toString, add and subtract. Method parse should receive a String, extract each digit using method charAt and place the integer equivalent of each digit into the integer vector. For comparing HugeInteger objects, provide the following methods: isEqualTo, isNotEqualTo, is Greater Than, isLessThan, is GreaterThanOrEqualTo, and LessThanOrEqualTo. Each of these is a predicate method that returns true if the relationship holds between the two HugeInteger objects and returns false if the relationship does not hold. Provide a rpedicate method isZero. If you feel ambitious, also provide methods multiply, divide and remainder. [Note: Primitive boolean values can be output as the word ❝true❝ or the word ❝false❝ with format specifier %b.]
public class HugeInteger
{
private int[] intArray;
private int numDigits; // stores the number of digits in intArray
public HugeInteger(String s)
{
intArray = new int[40];
numDigits = 0;
// call parse(s)
}
public HugeInteger( )
{
intArray = new int[40];
numDigits = 0;
}
public void parse(String s)
{
// Add each digit to the arrays
// update numDigits
}
public static HugeInteger add(HugeInteger hugeInt1, HugeInteger hugeInt2)
{
// Create hugeInt3
// Loop
// Add digits from hugeInt1 and hugeInt2,
// Store in corresponding hugeInt3
// End
//
// return hugeInt3
}
public static HugeInteger subtract(HugeInteger hugeInt1, HugeInteger hugeInt2)
{
// Create hugeInt3
// Loop
// Subtract hugeInt2 digit from hugeInt1,
// Store in corresponding hugeInt3
// End
//
// return hugeInt3
}
public static boolean isEqualTo(HugeInteger hugeInt1, HugeInteger hugeInt2)
{
// return true if the value represented by
// elements of hugeInt1.intArray is equal to
// value represented by elements of hughInt2.intArray
}
public static boolean isNotEqualTo(HugeInteger hugeInt1, HugeInteger hugeInt2)
{
// return true if the value represented by
// elements of hugeInt1.intArray is not equal to
// value represented by elements of hughInt2.intArray
}
public static boolean isGreaterThan(HugeInteger hugeInt1, HugeInteger hugeInt2)
{
// return true if the value represented by
// elements of hugeInt1.intArray is greater than
// value represented by elements of hughInt2.intArray
}
public static boolean isLessThan(HugeInteger hugeInt1, HugeInteger hugeInt2)
{
// return true if the value represented by
// elements of hugeInt1.intArray is less than
// value represented by elements of hughInt2.intArray
}
public static boolean isGreaterThanOrEqualTo(HugeInteger hugeInt1, HugeInteger hugeInt2)
{
// return true if the value represented by
// elements of hugeInt1.intArray is greater than or equal to
// value represented by elements of hughInt2.intArray
}
public static boolean isZero(HugeInteger hugeInt1 )
{
// return true if the value represented by
// elements of hugeInt1.intArray is 0
}
public String toString( )
{
// return string representation of this object
}
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 03:00
Which action describes an aspect of technological design?
Answers: 1
question
Computers and Technology, 22.06.2019 11:00
Lisa’s company, abc ltd., lost its biggest client and is now facing a financial crunch. most of her colleagues have resigned, but lisa decides to stay with the company and assist the management in overcoming the financial situation. which quality is lisa demonstrating? a. self-management b. cooperativeness c. responsibility d. loyalty
Answers: 2
question
Computers and Technology, 22.06.2019 22:00
Consider the following declarations (1, 2, 3, 5, 7)class bagtype{public: void set(string, double, double, double, double); void print() const; string getstyle() const; double getprice() const; void get(double, double, double, double); bagtype(); bagtype(string, double, double, double, double); private: string style: double l; double w; double h; double price; }; a.) write the definition of the number function set so that private members are set according to the parametersb.) write the definition of the member function print that prints the values of the data membersc.) write the definition of the default constructor of the class bagtype so that the private member variables are initialized to "", 0.0, 0.0, 0.0, 0.0, respectively d.) write a c++ statement that prints the value of the object newbag.e.) write a c++ statement that declares the object tempbag of type bagtype, and initialize the member variables of tempbag to "backpack", 15, 8, 20 and 49.99, respectively
Answers: 3
question
Computers and Technology, 22.06.2019 23:00
Which factor is the most important when choosing a website host? whether customers will make secure transactions the number of email accounts provided the purpose of the website the quality of the host control panel
Answers: 3
You know the right answer?
Create a class HugeInteger which uses a vector of digits to store huge integers. A HugeInteger objec...
Questions
question
Biology, 08.12.2021 19:40
question
Spanish, 08.12.2021 19:40
question
Mathematics, 08.12.2021 19:40
question
Spanish, 08.12.2021 19:40
Questions on the website: 13722363