Question
I am missing the min and max methods and cant get the calculator to output the way they have it. Java provides a class java.lang.BigInteger
I am missing the min and max methods and cant get the calculator to output the way they have it.
Java provides a class java.lang.BigInteger that can be used to handle very large integers. Implement a similar class, called BigInt, that can be used to do simple calculations with very large nonnegative numbers. Design thhis class carefully. You will need the following:"
- A data structure to represent large numbers: an ArrayList for the digits in a number.
- public BigInt( ArrayList val):
A constructor that uses a string representation of the integer for initialization. The string may contain leading zeros. Do not forget that zero is a valid number .
- public String toString():
Returns the String representation of this BigInt. It should not include leading zeros, but if the number consists of all zeros, it should return a String with a single zero.
- public BigInt max(BigInt val):
A method that returns a BigInt whose value is the maximum of val and the instance of BigInt that invokes max
. - public BigInt min(BigInt val):
A method that returns a BigInt whose value is the minimum of val and the instance of BigInt that invokes min.
- public BigInt add(BigInt val):
A method that returns a BigInt whose value is the sum of val and the instance of BigInt that invokes add.
- public BigInt multiply(BigInt val):
A method that returns a BigInt whose value is the product of val and the instance of Bigint that invokes multiply.
Write a program that acts as an interactive calculator capable of handling very large nonnegative integers that uses the BigInt class. This calculator need perform only the operations of addition and multiplication. In this program each input line is of the form num1 op num2 and should produce output such as
num1
op num2
----------------
num3
where num1 and num2 are (possibly very large) nonnegative numbers, op is the single character + or *, and num3 is the integer that results from the desired calculation. Be sure your interface is user friendly
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started