## CS 1401 Assignment #11

**Date Assigned:** Tuesday, November 15, 2005 or
Wednesday, November 16, 2005.
**Due Date:** before the end of the day on Wednesday, November 23,
2005 (i.e., before the Thanksgiving weekend).

**Goals:** to learn how to use for-loops and arrays.

**Points:**
This assignment is worth a total of 20 points. No late assignments
will be accepted, but credit will be given for partially completed
assignments turned in on time.

**Assignment:**

**Part I. For-Loops**

Write an application that asks the user for an integer between 1 and 10,
and then uses a nested for-loop to produce
a multiplication table similar to what is shown below.
For example, if the user enters a 5, the following output should be displayed:

X| 1 2 3 4 5
----------------------
1| 1 2 3 4 5
2| 2 4 6 8 10
3| 3 6 9 12 15
4| 4 8 12 16 18
5| 5 10 15 20 25

Use the variables *i* and *j* as loop counters.
Trace the execution of your code by hand, line by line, for a user input of 2. Show your tracing to your TA before submitting your program.
**Part II. Arrays**

Let us help the UTEP soccer team count the number of points they won. The results of all the games are stored in a file in which each line represents a score. For example, 5:3 means
that the UTEP team scored 5 goals, while the opposite team scored only 3 goals.

In soccer, a win (like 5:3) brings 2 points, a tie (like 3:3)
brings 1 point, and a loss (like 3:5) brings 0 points. The team with the largest number of points wins.
If two or more
teams get the same number of points, then the referees decide which of these teams is the champion by
looking at the overall numbers of goals scored and goals missed by each of these teams.

Write an application that:

- asks the user for a name of the file where the scores are stored;
you can assume that no more than 100 games were played;
- reads the scores from this file, line by line,
into two arrays:
- array
*scored*, and
- array
*missed*;

at the same time, the program should compute the overall
number of games played;
- computes and displays:
- the overall number of points gained by the UTEP team,
- the
overall number of goals scored by UTEP team, and
- the overall number of goals lost by UTEP team.

**Example**

If UTEP played 3 games, with scores 5:3, 1:2, and 7:0, then:

- in the first game, we gained 2 points;
- in the second game, we gained 0 points; and
- in the third game, we gained 2 points again.

The overall number of points gained is thus 2 + 0 + 2 = 4. Also:
- the overall number of goals scored is 5 + 1 + 7 = 13, and
- the overall number of goals missed is 3 + 2 + 0 = 5.

**Deliverables:** as announced in the labs.