CSSE 120 -- Intro. to Software Development

Homework 27

  1. There is no reading or ANGEL quiz due next session.
  2. (30 points) 2D Matrix Math. Checkout the MatrixFiles project from your repository. Add code in main.c to do the following:
    1. (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.
    2. 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.

    3. (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:
      1.25.0
      0.30.2
      2.7-5.6
      and
      6.01.3
      0.4-1.3
      -3.1-0.2
      are indicated by the file small.in in the Eclipse project.
    4. (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
      7.26.3
      0.7-1.1
      -0.4-5.8
    5. (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.
    6. Commit your work.
  3. (Optional) If you have time, you can read about your final C project, AroundTheWorld, to be assigned on Monday. You have already learned everything you need to do this project. An ambitious student could get a big jump by starting it and bringing questions about any difficulties to class on Monday.