Sunday, December 27, 2009

How to write this coding in JAVA?

*Design and implement a BigInteger class that can add and subtract positive integers with up to 25 digits (beyond the long data type).





*Your class should also include methods for input and output of the numbers.





*Your class also should have 3 instance String variables namely number1, number2 and result.





* It鈥檚 important to override the toString() method and constructors, which can be used in a wide variety of to display big integers and implementation.








Sample output is something like this:





big1 = 9999999999999999999999999999999999999999鈥?br>

big2 = 0000000000000000000000000000000000000000鈥?br>

--------------------------------------鈥?br>

sum = 1000000000000000000000000000000000000000鈥?br>




big3 = 9888888888888888888888888888888888888888鈥?br>

big4 = 0999999999999999999988876439999999999999鈥?br>

--------------------------------------鈥?br>

diff = 8888888888888888888900012448888888888888鈥?br>

How to write this coding in JAVA?
This is an excellent project assignment that you should work through yourself. It was one of my first real programming assignments and the solution would be a little long to post. Marshall Brain was my teacher (yep the one from ';How Stuff Works';) and he called it MINT for ';multi- precision integer'; The gotcha here is handling the carryover but it is not that hard.





This tutorial is for C++ but the concepts move right over to java.





http://www.see.ed.ac.uk/~sasg/Computers/鈥?/a>





Start in section 5.2





Good Luck!

No comments:

Post a Comment