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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 17:00, silvijaaa
The two main ways in which marketers address the competition with their strategies are by satisfying a need better than a competition and by
Answers: 2
image
Computers and Technology, 22.06.2019 17:00, hollodom9654
Which of the following is not contained on the slide show toolbar? a. next button b. slide button c. close button d. pen tool
Answers: 1
image
Computers and Technology, 22.06.2019 19:30, 710jonathan
The following is an excerpt from a slide presentation. today we will inverse operations solving equations using inverse operations solving inequalities using inverse operations from which part of the presentation does the slide most likely come from? a. introduction b. outline c. body d. conclusion
Answers: 1
image
Computers and Technology, 23.06.2019 12:20, jshhs
When guido van rossum created python, he wanted to make a language that was more than other programming languages. a. code-based b. human-readable c. complex d. functional
Answers: 1
You know the right answer?
Create a class HugeInteger which uses a vector of digits to store huge integers. A HugeInteger objec...

Questions in other subjects:

Konu
Mathematics, 10.06.2021 18:40
Konu
Mathematics, 10.06.2021 18:40
Konu
Mathematics, 10.06.2021 18:40