Write a function in Java that takes the int array arr
and returns a new array with each number being doubled. Be sure to make use of...
Search Results
Searching for: int
Individual Exercises
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,...
Return an array with the same contents, but double the size of the array passed in. The new slots will be filled with zeros. Use the...
In mathematics, the Fibonacci numbers are the numbers in the following integer sequence, characterized by the fact that every number...
Return the index of the last occurrence of a given number in an array. Return -1 if the number is not in the array.
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...
You have been handed a mysterious piece of data by an unknown person. Judging by his shifty eyes and maniacal laughter you don't think he...
Given a class Answer<E>
, write a method that converts argument e
into String and returns that value. If the value is a primitve, (...
Given an int
, return a double
of precisely half the initial value. The int
will need to be converted into a double
before any other...
Finish the code to complete the insertion sort method. Each comment denoted with //_________________ is a single line that needs to be...
What's wrong with the following code? Assume both the interface and class share the same package.
public interface Account { int...
Given a stack with Integers, write a function that pops the top two numbers from the stack, adds them together and pushes the result back...
Octavia has given you a list of movies. She is tired of deciding what to watch by name and now wants to be able to pick them by the...
You are in charge of keeping student records. Those records are recorded in a hash map that uses a student's ID number as the key in...
The mere presence of oversized arrays makes Priscilla Perfect sick to her stomach. Such wasted space is an imperfection she cannot bear....
Priscilla Perfect detests imperfection (hence the name). Write a program to analyze a given array and return true if the array is worthy...
[Based on an exercise at https://codeworkout.cs.vt.edu/]
Given two int
arrays a
and b
, each with two elements, return a new array with...
As a wild publicity stunt May Tricks has made her Middletown store disappear! You have no idea how she did this or if the store will ever...
Since May Tricks has proved to be a very unpredictable client you have decided to take extra precautions. By creating a remove vertex...
[Based on an exercise at https://codeworkout.cs.vt.edu/]
Given an array of int
values, return true if the group of n
numbers at the start...
[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...
[Based on an exercise at https://codeworkout.cs.vt.edu/]
Given an array containing three ints, return the sum of all the elements.
[Based on an exercise at https://codeworkout.cs.vt.edu/]
Write a function in Java that returns a version of the given array where all the...
Write a Java statement to declare an integer variable with the name hours
that has an initial value of 7.
Complete this method to print out the parameter.