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, 23.06.2019 14:00
How are stop motion special effects in animated films created
Answers: 1
question
Computers and Technology, 24.06.2019 02:00
Which steps will open the system so that you can enter a question and do a search for
Answers: 1
question
Computers and Technology, 24.06.2019 04:30
Fall protection, confined space entry procedures, controlled noise levels, and protection from chemical hazards are some of the things that contribute to a safe what
Answers: 1
question
Computers and Technology, 25.06.2019 08:50
1. define independent-set as the problem that takes a graph g and an integer k and asks whether g contains an independent set of vertices of size k. that is, g contains a set i of vertices of size k such that, for any v and w in i, there is no edge (v,w) in g. show that independent-set is np-complete.
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
Mathematics, 11.03.2021 21:20
question
Health, 11.03.2021 21:20
question
Mathematics, 11.03.2021 21:20
Questions on the website: 13722361