Programming and Problem Solving with Java

(やまだぃちぅ) #1
633

There is a line of data for each diver for each dive. All the data for Dive 1 are
grouped together, then all the data for Dive 2, then all the data for Dive 3.

Output
The input data, echo-printed in tabular form with appropriate headings—for
example, Name, Difficulty, Judge’s number (1–9)
A table that contains the following information:
Name Dive 1 Dive 2 Dive 3 Total
where Name is the diver’s name; Dive 1, Dive 2, and Dive 3 are the total points
received for a single dive; and Total is the overall total
5.You are to test what happens when overflow occurs. Write a simple application
that does the following tasks:
Calculate the factorial of an integer number
Embed the factorial in a loop that goes from 1 to 100
Print out the result of each factorial within the loop

Run your application with the factorial calculated using each of the integer
types. Record the results of each run.
Redo the experiment taking the factorial of a real number. Record the
results of each run.
Write a report describing what you learned about overflow and Java.
6.Extend the class UnsortedListso that the insertmethod creates a new array
that is twice the size of the current one when the list is full and moves the ele-
ments into it. Test your new class.

Case Study Follow-Up


1.There are no checks for row and column parameters being in bounds in the
Matrix Manipulation Case Study. List the methods where this error might
occur.
2.Implement checks for the out-of-bounds error described in Exercise 1 and
recode the solution.
3.Design and implement a test plan for the class Matrixas modified in Exercise 2.
4.The java.mathpackage contains the BigIntegerand BigDecimalclasses, which al-
low you to work with arbitrary-size and arbitrary-precision integers and float-
ing-point values. How would you have to change the class Matrixto define the
operations using BigIntegerrather than double?
5.Write a derived class of Matrixthat overrides the constructor which takes an
array as a parameter. The new version of the constructor should make a deep
copy of the array rather than a shallow copy.
Free download pdf