CS
1401 Introduction to Computer Science
Fall 2014, Lab 10
Motivation: to practice arrays of objects.
Assignment. Using the class Vector that you described in
Lab 9, in the main program, define and test several methods to
deal with arrays of vectors:
- write a method that asks
the user for the number of vectors, then for coordinates of each
vector, and returns the resulting array of vectors;
- write a
method that takes a vector a, and an integer n, and returns an
array of vectors which are all equal to a; for example, if a = (1, 2, 4)
and n = 3, then this method should return an array b consisting of
three identical vectors b[0] = (1, 2, 4), b[1] = (1, 2, 4), and
b[2] = (1, 2, 4)
- write a method
that, given two arrays of vectors a[n] and b[n] (of the same
size), returns the sum of their dot products: (a[0], b[0])
+ (a[1], b[1]) + ... + (a[n − 1], b[n −
1]).
Test your methods by calling them in the main
method.
When it is due. The program is due at the beginning of the
second lab section on the week of November 17, i.e.:
- on
Wednesday November 19 for those who attend Monday-Wednesday labs,
and
- on Thursday November 20 for those who attend
Tuesday-Thursday labs.