CS10, 09S, UCSB
H04: Homework 4 (Based on Horstman, Chapter 4) Total points: ?
Accepted: on paper, in lecture (1-1:50pm) on Friday, April 10th only.
No email submission allowed.
Name: (2 pts)______________________________ UCSBNetID (2 pts) _____________________
Section (2 pts) Circle one: Thu 4pm Fri 10am Fri 11am Fri noon
- (5 pts) Fill in the blank:
Chapter 4 indicates that every value in Java is either a/an _____________ or it is one of eight primitive types.
- (5 pts) Fill in the blank:
Chapter 4 indicates that of the eight primitive types in Java, six are number types. What are the other two?
_______________________ and ________________________
- (6 pts) We can convert a floating point value (i.e. the float or double type) into an integer using a cast.
Here is a statement that declares a varaible called accurateTemperature and assigns in the value 98.6.
double accurateTemperature = 98.6;
Now, write a Java statement that uses a cast to declare and assign an integer variable approxTemp that has an integer approximation of the value of accurateTemperature.
- (6 pts) In Java, what is the value of
56 % 7
- (6 pts) In Java, what is the value of
9 / 5
- (10 pts) Suppose that we have this variable:
double angleInDeg;
Assume that angleInDeg already has been assigned a value. Write a Java statement (or series of statements) that will declare a variable called theSine that contains the sine of that angle. (Note: You'll need to use two function calls—one to convert from degrees to radians, and another to compute the sine.)
- (6 pts) The methods use use to compute square root, sin, cos, etc. are static methods. What is different about using a static method, vs, using a non-static method? (You'll find the answer in Chapter 4.)
End of H04