Ask Question
27 September, 09:42

Row array gameScores contains all player scores. Construct a row array highScores than contains all player scores greater than minScore. Hint: meetsThreshold is a logic array that indicates which elements in gameScores are greater than minScore.

Ex: If gameScores is [2, 5, 7, 6, 1, 9, 1] and minScore is 5, then highScores should be [7, 6, 9].

function highScores = GetHighScores (gameScores, minScore)

% gameScores: Array contains all player scores

% minScore: Scores greater than minScore are added to highScores

meetsThreshold = (gameScores > minScore); % Logic array indicates which

% elements are greater than minScore

% Construct a row array highScores containing all player scores greater than minScore

highScores=0;

end;

+3
Answers (1)
  1. 27 September, 10:26
    0
    The solution is written using Python as it has a simple syntax.

    def getHighScores (gameScores, minScore) : meetsThreshold = [] for score in gameScores: if (score > minScore) : meetsThreshold. append (score) return meetsThreshold gameScores = [2, 5, 7, 6, 1, 9, 1] minScore = 5 highScores = getHighScores (gameScores, minScore) print (highScores)

    Explanation:

    Line 1-8

    Create a function and name it as getHighScores which accepts two values, gameScores and minScore. (Line 1) Create an empty list/array and assign it to variable meetsThreshold. (Line 2) Create a for loop to iterate through each of the score in the gameScores (Line 4) Set a condition if the current score is bigger than the minScore, add the score into the meetsThreshold list (Line 5-6) Return meetsThreshold list as the output

    Line 11-12

    create a random list of gameScores (Line 11) Set the minimum score to 5 (Line 12)

    Line 13-14

    Call the function getHighScores () and pass the gameScores and minScore as the arguments. The codes within the function getHighScores () will run and return the meetsThreshold list and assign it to highScores. (Line 13) Display highScores using built-in function print ().
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Row array gameScores contains all player scores. Construct a row array highScores than contains all player scores greater than minScore. ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers