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...
Search Results
Searching for: mod
Individual Exercises
Write a function in Java that takes an int
array as its parameter and returns the number of even int
s it contains. Note: the %
"mod"...
Given an array of int
values, return true if the array contains either 3 even or 3 odd values all next to each other.
For each multiple of 10 in the given array, change all the values following it to be that multiple of 10, until encountering another...
We want make a package of goal
kilos of chocolate. We have small bars (1 kilo each) and big bars (5 kilos each). Return the number of...
Given a non-negative int n
, return the sum of its digits recursively (no loops). Note that mod (%
) by 10 yields the rightmost digit (126...
Given a non-negative int n
, compute recursively (no loops) the count of the occurrences of 8 as a digit, except that an 8 with another 8...
Given a non-negative int n
, return the count of the occurrences of 7 as a digit, so for example 717 yields 2. (no loops). Note that mod (...
Given two integers, return true if the first number is evenly divisible by the second, and false otherwise. Return false if the second...
Complete this method so it prints out the remainder of the two parameters.
Fill in the correct access modifier to make this method only accessible by the class it is in. Return the correct boolean that indicates...
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...
Initialize the variables quotient
and mod
below and add them in the correct locations to create the correct result. The method should...
Initialize the variables below and add them in the correct locations to create the correct result. For example, if variableModString(2,...
Fill in the if statement in the following method. The method should return "Divisible!" if the parameter x is eveny divisible by 5....
The following method takes in a 2D array of characters. for each row at an even index, change every item in that row to '*'.
For example:...
The following method takes in an int
representing some number of inches. Implement it so that it returns a string reporting the number of...
For this question assume the following implementations of Computer, Tablet, and Notebook
public class Computer { private String...