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

 

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

Write a method that returns the sum of all the numbers in array 'nums' but not including any numbers that match the value of 'excluded'. Array 'nums' can be any length, including length zero. Each number could be positive, negative, or zero. All numbers are included in the sum except 'excluded'. For example, if 'nums' is {5,7,3,1,10,2,7} and 'excluded' is 7, the sum would be 5+3+1+10+2 which is 21. Look at the test data for more examples.


test2022_12_08_APP1SLHL_sumExcluding([1, 2, 3, 4, 5, -10, 40, 50, 100, -2, 3], 100) → 96
test2022_12_08_APP1SLHL_sumExcluding([50, 60, 20, 40, 20], 20) → 150
test2022_12_08_APP1SLHL_sumExcluding([-1, -2, -3, -4, -5], -5) → -10

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

public int test2022_12_08_APP1SLHL_sumExcluding(int[] nums, int excluded) { }

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: 210

Copyright Nick Parlante 2017 - privacy