CS 1401, Quiz 12 based on Test 3, TR version

Date: Monday, December 1, 2014
Name (please type legibly, ideally in block letters): ______________________________________________________________________

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.