Given an array of integers, return the sum of every other value in the array, starting with the first element. For example, if the array...
Search Results
Searching for: loops
Individual Exercises
Given an array of integers, return the average of all values in the array as a double
. For example, if an array containing the values...
Given two integers size
and num
, return an array that can hold size
integers and is filled with multiples of num
, starting with num
. For...
Given an array of String
s, return a single String
that is made up of all strings in the array concatenated together in order. For...
Given an array of String
s, return a single String
that is made up of all strings in the array concatenated together in reverse order. For...
Given an array of integers and an integer target
, return a count of the number of times the target
value occurs in the array.
Given an array of integers, return the largest value that occurs in the array. You may want to use the constant Integer.MIN_VALUE
, which...
Given an array of integers, return the smallest value that occurs in the array. You may want to use the constant Integer.MAX_VALUE
, which...
Given an array of double
values that contains the prices of merchandise, return the range of the prices (the difference between the...
Given an array of integers, swap each pair of adjacent elements starting with the first two. For example, if the array contains the...
Given a String
, return an array of char
values that contains the characters of the string in reverse order. For example, if the string is...
Given two strings of equal length, return an array of char
values that contains the characters of the strings in alternating order. For...
Mars' new colony needs your help. This morning, a flurry of distress signals reached Earth, each encrypted with a secret message....
Complete the hashing algorithm for a hash table so that it functions using open addressing. Remember to store both keys and values in...
Given a string str
and an int n
, return a string made of the first n
characters of the string, followed by the first n - 1
characters of...
[Based on an exercise at https://codeworkout.cs.vt.edu/]
Given an array of Strings, return a single String that is made up of all strings...
This method takes an integer array as a parameter and returns true if the array includes an odd integer; otherwise, the method returns...
This method accepts two integer arrays as its parameters and returns a new array, which contains all of the elements of first parameter...
This method takes a String object as a parameter and returns a compressed version of the object. The method compresses the String by...
This methods takes a String object as a parameter and returns an encrypted version of the object. The encryption is done in two steps:...
This method simulates flipping a fair coin. It takes an integer parameter, which specifies the number of times that the coin is to be...
This method simulates flipping a fair coin. The coin is flipped repeatedly until three consecutive heads are seen. The method takes an...
This method simulates flipping a fair coin. The coin is flipped repeatedly until three heads are seen. The method takes an integer...
This method takes an ArrayList of Strings as a parameter and returns the longest String in the list. If the list is empty, it should...
This method takes an ArrayList of Strings as a parameter and returns the length of the longest String in the list. If the list is empty,...