CS 1401,
Quiz 13 (based on Test 4), MW 12-1:20 pm version
Date: Wednesday, December 4, 2013
Name (please type legibly, ideally in block letters):
______________________________________________________________________
1. Suppose that a class Discovery has already been defined,
whose objects are different discoveries. The description of each
discovery contains:
- its title,
- the corresponding
investment, and
- the corresponding profit.
As usual, this
class contains: - a constructor method,
- get- and
set-methods, and
- a method for computing the discovery's
profitability -- which is defined as the profit divided by the
investment.
1a. Write a method that, given an array of discoveries, returns the
title of the most profitable discovery.
1b. In the main program, create an array s consisting of two
new objects of type Discovery:
- an object describing
the computer which earned the profit of $200,000,000 after an
investment of $10,000,000, and
- an object describing the car
for which the profit was $100,000,000,000 on the investment of
$10,000,000,000.
1c. In the main program, apply your method to the array s,
and trace the resulting code step-by-step.