## CS 1401, Exam #3, MW version

Date: Wednesday, November 19, 2014
Name (please type legibly, ideally in block letters): ______________________________________________________________________

Exactly 45 years ago, on November 19, 1969, the legendary Brazilian football (soccer) player Pele scored his 1,000-th goal.

1a. Write a method named average that, given the total number of goals scored by the player and the starting and ending years, returns the average number of goals per year scored by the player.

1b. In the main method, call your method average to compute the average number of goals scored by Vladik Kreinovich, who played (when at school) for 4 years and scored 1 goal.

1c. Trace, step-by-step, how the computer will perform all the needed computations, and check that the result is indeed correct.

```

```
2a. Define a class Footballer whose objects are different football players. The description of each player should contain his/her name, country, number of years played, and number of goals scored. Your class should contain a constructor method, get- and set-methods, and a method for computing the average number of goals scored per year.

2b. Use your class in the main method to define a new object pele of type Footballer describing Pele at the end of 1969, when he scored 1,008 goals during the 14 years of his career (he started in 1955). Compute and print the average number of goals that Pele scored per year. Then, update the values based on the year 1970, during which he has scored 72 more goals, and compute and print the new average.

```

```
3a. Which football player scored the most goals? To answer this question, write a method that, given an array g of goals scored by different players and an array n of their names, returns the name of the highest-scoring player.

3b. To check the correctness of your method, test it on the example of two arrays: array players with elements Pele and Kreinovich, and array goals with values 1,008 and 1.

3c. Trace step-by-step how the piece of code you wrote in Part 3b finds the name of the player who scored the most goals.

```

```
4a. Suppose that a football player gets a certain monetary bonus for each goal. Write a method that, given an array of goals scored by different players and a bonus-per-goal value, returns a new array with the amounts given to each player.

4b. To check the correctness of your method, test it in the main program on the example of an array g consisting of 1,008 and 1 goals, and a bonus of \$100 per goal.

4c. Trace step-by-step what happens when you run the piece of code you wrote in Part 4b. The result should be an array consisting of values \$100,800 and \$100.

```

```
5. Describe the main teamwork roles, and what are the main tasks of the corresponding persons.

```

```
6. Describe what is white-box testing and what is black-box testing. Describe the main rules for testing; give an example for each rule.