id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > quiz2023_04_25_APP1SLHL_sumMask
prev  |  next  |  chance

Write a method that returns the sum of the desired numbers from the 'nums' array. Only use numbers that are in the same position in the 'nums' array as a value of TRUE in the 'include' array. For example, if 'nums' is {7,9,15,20,33} and 'include' is {true,false,false,true,false}, you would return 27 because 7+20=27 (since 7 and 20 were in the same position as a 'true' value in 'include'). Note: If the entire 'include' array contains 'true', you will return the sum of ALL the numbers in 'nums'. If the entire 'include array contains 'false', you will return a zero. Preconditions: 'nums' can contain any integers and can be any length, including a length of zero. The length of 'nums' and the length of 'include' are the same.


quiz2023_04_25_APP1SLHL_sumMask([], []) → 0
quiz2023_04_25_APP1SLHL_sumMask([53, 64, 80], [false, false, true]) → 80
quiz2023_04_25_APP1SLHL_sumMask([1, 2, 4, 8, 16, 32], [true, true, true, true, true, true]) → 63

...Save, Compile, Run (ctrl-enter)

public int quiz2023_04_25_APP1SLHL_sumMask(int[] nums, boolean[] include) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 230

Copyright Nick Parlante 2017 - privacy