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_P1SLHL_sumMults
prev  |  next  |  chance

Write a method that returns the sum of selected numbers from the 'nums' array. Only use numbers that are a multiple of 'multOf'. For example, if 'multOf' was 3, you would only use the numbers in 'nums' that are multiples of 3 in finding the sum. So, if 'nums' is {7,9,15,20,33} and 'multOf' is 3, you would return 57 because 9+15+33=57 (since 9, 15, and 33 were the only multiples of 3 in the array, they were the only numbers that counted towards the sum). Note: If 'multOf' is 1, you will return the sum of ALL the integers in 'nums' because all numbers in the array must be multiples of 1. Preconditions: 'nums' will only contain positive integers, but can be any length, including a length of zero. The parameter 'multOf' will be a positive integer.


quiz2023_04_25_P1SLHL_sumMults([12, 35, 54, 124, 567, 24, 142, 6, 35, 75, 21, 856, 35, 85, 124, 3456], 6) → 3552
quiz2023_04_25_P1SLHL_sumMults([], 1) → 0
quiz2023_04_25_P1SLHL_sumMults([], 5) → 0

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

public int quiz2023_04_25_P1SLHL_sumMults(int[] nums, int multOf) { }

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