Given a day of the week encoded as 0 = Sun, 1 = Mon, 2 = Tue, ... 6 = Sat, and a boolean indicating if we are on vacation, return a...
Search Results
Searching for: if
Individual Exercises
The number 6 is a truly great number. Given two int
values, a
and b
, return true if either one is 6. Or if their sum or difference is 6....
When squirrels get together for a party, they like to have cigars. A squirrel party is successful when the number of cigars is between 40...
You and your date are trying to get a table at a restaurant. The parameter you
is the stylishness of your clothes, in the range 0..10,...
You have a green lottery ticket, with int
s a
, b
, and c
on it. If the numbers are all different from each other, the result is 0. If all...
Write a method called listSearch()
that takes in a target string and a list of other strings. This method returns a (possibly shorter)...
Iterate through the given array and return the number of fours.
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 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...
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)...
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 that returns true if a
is even, false otherwise. Just for practice, you must use an if
statement.
Complete this method so it prints out the difference between the two parameters.
This method returns the value of the minimum element in the subsection of the array "y", starting at position "first" and ending at...
Fill in the correct access modifier to make this method only accessible by the class it is in. Return the correct boolean that indicates...
Based on three scores that the user inputs, display the average of the scores and the letter grade that is assigned fort he test score...
A magic date is one when written in the following format, the month times the date equals the year e.g. 6/10/60. Write code that figures...
Wilson’s Shipping Company charges the following rates:
Weight of Package
Rate per 500 Miles Shipped
2 pounds or less
$1.10
Over 2 lbs...
You are writing code using a jeroo named jamie
. Change the else clause so that jamie
will turn right instead of hop when there is no...
You are writing code using a jeroo named jamie
. Change the code so that jamie
will turn right if a flower is to the right, or hop...
You are writing code using a jeroo named jamie
. The following if-then-else statement will not compile because of a syntax error. Fix the...