Write a function in Java that implements the following logic: The squirrels in Palo Alto spend most of the day playing. In particular,...
Exam 1 Retake Quals
Score: 0 / 53.0
Exercises
Write a function in Java that implements the following logic: Given a non-negative number num, return true if num is within 2 of a...
Write a function in Java that implements the following logic: Given three ints, a, b, and c, return true if it is possible to add two of...
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: You have a blue lottery ticket, with ints a, b, and c on it. This makes...
Write a function in Java that implements the following logic: Given 2 int values greater than 0, return whichever value is nearest to 21...
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 counts the number of times the string "code" appears anywhere in the given string str, except that we'll...
For each multiple of 10 in the given array, change all the values following it to be that multiple of 10, until encountering another...
Given an integer array length of 1 or more, return the difference between the largest and smallest values in the array. Note that the...
Given an array of ints, return true if the number of 1s is greater than the number of 4s. Otherwise, return false.
Given an array of ints, if it contains no 1's return true. If it contains no 4's, return true. If it contains both, return false.
Consider the leftmost and righmost appearances of some value in an array. We'll say that the span is the number of elements between the...
Say that a "clump" in an array is a series of 2 or more adjacent elements of the same value. Return the number of clumps in the given...
Return an array that contains the exact same numbers as the given array, but rearranged so that all the even numbers come before all the...
Given a string of any length, return a new string where the last 2 chars, if present, are swapped, so "coding" yields "codign".
Return true if somewhere in the array, there are three increasing adjacent numbers like .... 4, 5, 6, ... or 23, 24, 25.
Given n >= 0, create an array of length n * n with the following pattern, shown here for n = 3 : {0, 0, 1, 0, 2, 1, 3, 2, 1} (spaces...
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...
You have a green lottery ticket, with ints a, b, and c on it. If the numbers are all different from each other, the result is 0. If all...
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,...
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...
Given a string, return the length of the largest "block" in the string. A block is a run of adjacent chars that are the same.
Given two integers, return true if the first number is evenly divisible by the second, and false otherwise. Return false if the second...
Given an integer representing the radius of a sphere, compute and return the sphere's volume based on the following formula:
Volume = 4/3...
Given three double values representing prices, return the smallest price. For example, if the values passed in are 19.95, 12.85, and...
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 array of integers, return the sum of all values in the array.
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...
The local library needs help keeping track of overdue books. Currently, the library has a record of each book checked out but wishes to...
The Student Chapter for the Association for Computing Machinery (ACM) requested your help. Throughout the semester, attendance for the...
Iterate through the given array and return the number of fours.
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,...
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...
Return the index of the last occurrence of a given number in an array. Return -1 if the number is not in the array.
Which lines contain the fields?
public class Test { private final int SHIRTS = 24; private int numPants= 14; private int tanks =0; public...
Which lines contain the constructor?
public class Test() { private final int SHIRTS = 24; private int numPants= 14; private int tanks =0;...
declare a variable with the appropriate data type to have a statement that says: “Good Morning.” Use the variable you created in the...
This method returns the price of bread. Declare a variable called “price of bread” using camel case and the correct data type in the...
What datatype should you use to store a Middle initial?
What is the value of variable donuts after the following code executes?
int donuts = 6; donuts = donuts + 3; donuts = donuts * donuts;
What is the scope of the variable spicy?
int peper = 7; int cumin = 17; if ((pepper>5) && (cumin < 20)) { int spicy = 10;...
What is the scope of the variable cumin?
int peper = 7; int cumin = 17; if ((pepper>5) && (cumin < 20)) { int spicy = 10;...
Write a function in Java that calculates a total cost with tax and tip. Given three doubles: basePrice, taxRate (as a decimal, e.g., 0.08...
Write a function in Java that calculates what grade a student needs on the next quiz to reach a target average. Given three ints:...
Write a function in Java that calculates the average speed of a trip. Given four ints: distance (miles), days, hours, and minutes;
...
Write a function in Java that calculates the difference between the volumes of two cubes. Given two doubles: sideLength1 and sideLength2...
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...
create a print line that will cast integer division m as an double.
What value is stored in myInt after casting happens during the assignment in the second line of code.
double myDouble = 9.55; int myInt =...
What value is stored in myDouble after casting happens during the assignment in the second line of code?
int myInt = 9; double myDouble =...