Given an int[] nums
array, return the sum of the first five elements from the array. Note that nums
could have fewer than five elements,...
Search Results
Searching for: io
Individual Exercises
Create an enhanced for loop that iterates to each String in the array words
and returns true when there is at least one String with more...
Complete the method so that the number num
is set to index point index
in the array named array
. Be sure to handle the exception with the...
Surround the appropriate lines of code with a try catch block so that first, an exception is caught when the String index is out of...
Create a method that returns the third character from the String word
. Be sure to use a try catch block and use the appropriate exception...
Considering the following lines of code, what will be the output?
try { String str = null; System.out.println(str.charAt(0)); }...
In mathematics, the Fibonacci numbers are the numbers in the following integer sequence, characterized by the fact that every number...
Write a function findEvenQueue
that returns the first even number in the Queue. The function looks at the value at the front of the queue...
Return the index of first four in an array. Return -1 if there are none.
The following method is a Selection Sort method. Within the method, there is an error on one line. You job is to find that line and fix...
The method mapNums returns a HashMap that stores values of how many times a given key digit has appeared in an input String. Write a...
Roxy has written a method to count the number of people in her neighborhood, excluding children under 16 and individuals who are only...
Finish the code to complete the insertion sort method. Each comment denoted with //_________________ is a single line that needs to be...
Use the following recursive method:
public int mysteryMethod(int n) { if (n < 0) { return 5; } else { return mysteryMethod(n - 1) +...
Complete the hashing algorithm for a hash table so that it functions using open addressing. Remember to store both keys and values in...
In mathematics, the Perrin Numbers are defined by the recursion relation
P(n) = P(n - 2) + P(n -3) for n > 2
with initial values
P(0)...
Write a method quicksort that takes in an ArrayList of integers and returns them in ascending order, using a quicksort style of sorting....
Write an algorithm that takes an ArrayList and uses a recursive binary search to return both the index of a given String, or -1 if the...
Design a recursive method for scrambling Strings of length 3 or more. It must swap the first and last character of the input String, then...
A local grocery store has asked you to design a method to verify if their produce is okay to put on the shelves. The method takes an...
The method wabbajack()
is defined as follows:
public String wabbajack(String input) { if (input.length() < 5) { return "Rabbit"; }...
A string is a palindrome if it reads the same forward and backward, with case insensitivity. For example, the words "mom", "dad", "Mom",...
Write a function in Python called 'factorial()' that will take a positive integer as input and returns its factorial as output....
Write a function in C++ called 'factorial' that will take a positive integer as input and returns its factorial. In math, a factorial is...
Write a function in Ruby called 'factorial()' that will take a positive integer as input and returns its factorial as output. backwards.
...