1. Consider the method call Math.pow(3,2). What are the arguments & return value
ID: 3755766 • Letter: 1
Question
1. Consider the method call Math.pow(3,2). What are the arguments & return values?
2. The Math.ceil() method in the Java standard library is described as follows: The method receives a single argument a of type double and returns the smallest double value >= a that is an integer. What is the return value of Math.ceil(2.3)?
3. Is it possible to determine the answer to Self Check 3 without knowing how the Math.ceil method is implemented? Use an engineering term to describe this aspect of the Math.ceil method.
4. What is the value of cubeVolume(3)? (see Cubes.java program on page 206)
5. Declare a method squareArea that computes the area of a square of a given side length. (Recall that the area is equal to the sideLength multiplied by the sideLength)
6. Consider this method:
public static int mystery(int x, int y) {
double result = (x + y) / (y - x);
return result;
}
What is the result of the call mystery(2,3)?
Explanation / Answer
1. Consider the method call Math.pow(3,2). What are the arguments & return values? 3 and 2 are arguments. 9.0 is the return value. 2. The Math.ceil() method in the Java standard library is described as follows: The method receives a single argument a of type double and returns the smallest double value >= a that is an integer. What is the return value of Math.ceil(2.3)? 3.0 is the return value. 3. Is it possible to determine the answer to Self Check 3 without knowing how the Math.ceil method is implemented? Use an engineering term to describe this aspect of the Math.ceil method. Yes, it's possible. because finding a ceil of a number is a very common mathematical function. 4. What is the value of cubeVolume(3)? (see Cubes.java program on page 206) Need "Cubes.java program on page 206" to solve this 5. Declare a method squareArea that computes the area of a square of a given side length. (Recall that the area is equal to the sideLength multiplied by the sideLength) public static int squareArea(int sideLength) { return sideLength * sideLength; } 6. Consider this method: public static int mystery(int x, int y) { double result = (x + y) / (y - x); return result; } What is the result of the call mystery(2,3)? result of mystery(2, 3) is 5.0
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.