Question: The programming term mask refers to an array or 0s and 1s that is built from another array, such that if any element in the

  1. The programming term mask refers to an array or 0’s and 1’s that is built from another array, such that if any element in the other array satisfies some criterion, the corresponding mask element is 1. Otherwise that corresponding mask element is 0. Suppose each row in a two-dimensional array named births contains the birth years of children in one family. And suppose we want a method named getVotingMask to return a mask whose 1 or 0 elements indicate whether a child is at or above age 18, the legal age to vote in America. The getVotingMask method’s first parameter is a reference to the births array and its second parameter is the current year. We want the method to return a mask whose elements are 0 if the corresponding child is under 18 or a 1 if the corresponding child is 18 or over. Supply the missing code in the following getVotingMask method:

static int[][] getVotingMask( int[][] birth, int currentYear) { int[][] mask = new int[birth.length][]; int[]

static int[][] getVotingMask(int[][] birth, int current Year) { int[][] mask = new int[birth.length][]; int[] row; for (int i-0; i

Step by Step Solution

3.46 Rating (146 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The missing code needs to create a row of the mask for each family based on the ages of the children ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Introduction To Programming With Java A Problem Solving Approach Questions!