Assignment for CBOP 3203 OBJECT ORIENTED PROGRAMMING
QUESTION 1
Write a program that contains y array and the z array. Both arrays have the same size. Assign {6,1,5,9,5} to y and {2,13,6,15,2} to z. The program also has a method called sumLargeNumber( ) which has the following header:
int sumLargeNumber(int a[],int b[], int size)
The method will compare the values in both arrays and sum up all the elements that are the larger value at each index position. This sum will be the returned value of the method. For example:
int[] y = {6,1,5,9,5}
int[] z = {2,13,6,15,2}
The sumLargeNumber(y, z, 5) will return 45 (6+13+6+15+5).
Write the complete and practical program for the above problem.
(20 marks)
QUESTION 2
Implement a class named threeDPoint that models a location in (x,y,z) coordinate space. The class contains:
• A double data field named X that specifies x coordinate in a three dimensional Cartesian coordinate system
• A double data field named Y that specifies y coordinate in a three dimensional Cartesian coordinate system
• A double data field named Z that specifies z coordinate in a three dimensional Cartesian coordinate system
• A no-arg constructor that creates a default point 0.0 for all the data fields
• A constructor that creates an instance with the specified x-, y-, and z-coordinates.
• The accessor (get) and mutator (set) methods for all three data fields.
• A method named toString () that returns a string description for the point.
Then, create an object of the above class in a new program that has the main() method. All the inputs for the object must be captured in the main() method interactively.