Cryptography Reference
In-Depth Information
public double doubleValue()
This method converts
number to a double. It is similar to the double-to-float nar-
rowing primitive conversion defined in The Java Language Specification: If the number
has too great a magnitude to represent as a double, it will be converted to infinity or nega-
tive infinity as appropriate.
this
EXERCISES
1.
Write the following Java methods for the Int class:
public Int[] divideAndRemainder(Int other);
public Int divide(Int other);
public Int remainder(Int other);
The first returns both the quotient and remainder of one Int object divided by another.
(This is more efficient since you will probably compute both quantities at the same
time anyway.) Return these two values as an array of two Ints; answer[0] could contain
the quotient, and answer[1] could contain the remainder. The second and third meth-
ods return the quotient and the remainder of Int division, respectively.
2.
Design a graphical calculator for Int objects, with buttons to perform addition, multi-
plication, subtraction, and division. If desired, write methods to perform other opera-
tions with Ints, and supply buttons for these on the calculator. Establish precedence
among your operators, and include parentheses buttons to override precedence rules.
Search WWH ::




Custom Search