- (3 points) Add appropriate comments at the top of the file.
Also make sure you add comments within your code as you go, as
usual.
The user will be asked for a base name (a string) from which the input and output filenames will be constructed by adding .in and .out.
For example, if the user enters numbers
, the input file will be numbers.in
and the output file will be numbers.out
.
- (10 points) Prompt the user for the base name. Then read in two matrices (2D arrays) of floats from
the input file.
The input file will be formatted as follows. The first line will contain the number of rows, then the number of columns,
separated by a space. The next set of lines will contain the numbers of the first matrix.
Each row's numbers will appear on one line, separated by spaces.
A single blank line will separate the two matrices. The next set of lines will contain the numbers of the second matrix in the same form.
For example, the following matrices:
and
are indicated by the file
small.in
in the Eclipse project.
- (7 points) Create a new matrix to hold the sum of the two matrices read in, and fill it with the sum of those matrices. Recall that the sum of two matrices is just computed element-by-element.
For example, the sum of the two matrices above is
- (10 points) Write out the resulting matrix to the output
file.
The columns must line up nicely, with results displayed to the
thousandth place. When choosing the total width, you may
assume that the results will be no larger than 99.9.
- Commit your work.