[Based on an exercise at https://codeworkout.cs.vt.edu/]

Write a function in Java that takes an `int`

array as its parameter. It should...

# Search Results

Searching for: sum

## Individual Exercises

Complete this method to return the sum of the two parameters.

Create a print line that sums variable a and variable b.

Finish the for loop below. This method should return an `int`

representing the sum of the numbers from 1 to the parameter `n`

. For example,...

Write a function in Java that implements the following logic: Given 2 ints, a and b, return their sum. However, sums in the range 10..19...

Write a function in Java that implements the following logic: Given 2 ints, `a`

and `b`

, return their sum. However, "teen" values in the...

Write a function in Java that implements the following logic: Given 3 int values, `a`

, `b`

, and `c`

, return their sum. However, if one of the...

Write a function in Java that implements the following logic: Given 3 int values, `a`

, `b`

, and `c`

, return their sum. However, if one of the...

Write two methods in Java that implements the following logic: Given 3 int values, `a`

, `b`

, and `c`

, return their sum. However, if any of the...

Given an array containing three ints, return the sum of all the elements. It is safe to assume that the array always has at least 3...

Given an `int`

array, return the sum of the numbers in the array, except ignore sections of numbers starting with a 6 and extending to the...

Write a function in Java that takes an array and returns the sum of the numbers in the array, or 0 if the array is empty. Except the...

Given an array of `int`

s, return `true`

if the sum of all the 2's in the array is exactly 8.

For this problem, we'll round an `int`

value up to the next multiple of 10 if its rightmost digit is 5 or more, so 15 rounds up to 20....

Given a non-negative int `n`

, return the sum of its digits recursively (no loops). Note that mod (`%`

) by 10 yields the rightmost digit (126...

Given a string, return the sum of the numbers appearing in the string, ignoring all other characters. A number is a series of 1 or more...

For function `sumtok`

, write the missing recursive call. This function returns the sum of the values from 1 to `k`

.

For function `sumOfDigits`

, write the missing recursive call. This function takes a non-negative integer and returns the sum of its digits....

Write a recursive function that takes a start index, array of integers, and a target sum. Your goal is to find whether a subset of the...

We define a "root-to-node path" to be any sequence of nodes in a tree starting with the root and proceeding downward to a given node. The...

Write a recursive function `int BTsumall(BinNode root)`

that returns the sum of the values for all of the nodes of the binary tree with...

Given a binary tree, check if the tree satisfies the property that for each node, the sum of the values of its left and right children...

Given two integers `low`

and `high`

representing a range, return the sum of the integers in that range. For example, if `low`

is 12 and `high`

is...

Given an integer `num`

, return the sum of the multiples of `num`

between 1 and 100. For example, if `num`

is 20, the returned value should be...

Given an array of integers, return the sum of all values in the array.