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.


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:


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

The overall number of points gained is thus 2 + 0 + 2 = 4. Also:

Deliverables: as announced in the labs.