home—info—exams—lectures—labs—hws
Recipe—Laws—lies—syntax—java.lang docs—java.util docs
hw00
hw00
Introductions; finger exercises
Due Date: Jan.15 (Mon.)16 (Tue, post-MLK day), 17:00.
1
Instructions:
-
Type in answers to each of the following questions, in a computer file
(any text editor will do fine 2).
-
Save your as a text file, and submit it via Blackboard.
[via Blackboard > Course Tools > Assignments > hw00 > Add attachment.]
-
In addition, turn in a hardcopy as you come to class.
All homeworks will work the same way:
submit via Blackboard, and turn in a hardcopy in class.
-
Problems worth 0pts don't require an answer.
For problems asking you to do some other task (e.g. ‘post on Blackboard’)
you can just say something like ‘done’.
-
(nickname, 1pt) What name do you prefer to go by?
-
(major, 1pt) What is your major, and how confident are you of this?
(give a number in [0,1]—so 50% means you're giving even odds
on whether you'll graduate with that as your major).
-
(faveCourse, 1pt)
Out of the other courses you are taking this semester,
which one is shaping up to be the most interesting?
-
(fave, 1pt)
Write down a category (in object-oriented terms, a “class,”),
and a most-favorite or least-favorite instance of that class.
(For example:
“My favorite powerpuff girl: Buttercup.”
or
“Class: Musical genres; Least favorite instance: Polka.”)
-
(Blackboard, 1pt)
Post your previous answer
to the class Discussion Board, in Blackboard.
-
(learning style, 3pts)
Take the
Index
of Learning Styles Questionnaire.
What are your four scores? (e.g. “ACT 5, INT 2, …”.
Be sure to include the name with each number;
if you only write “5”, I can't tell if you mean
“ACT 5” or “REF 5”.)
-
(0pts)
In Blackboard, you'll find a passel of ITEC120 courses listed:
a class and lab (L) entry for your particular section,
plus a class and lab entry “ITEC120-Barland (All Sections)”
or “ITEC120-Pittges (All Sections)”.
We will only use the All Sections class.
The other three Blackboard entries will just clutter
your Blackboard view for the semester,
unless you click on the pencil icon in the upper-right
of your list, and choose to "Hide Link" for other ITEC120 entries.
- (5pts)
What do each of the following Java expressions evaluate to?
Before typing them in, think to yourself what you think the
answer should be; feel free to note if any surprising or puzzling results.
- 2+3*4
- 2+(3*4)
- (2+3)*4
- 12.0 / 5.0
- 12 / 5
- 12 % 5
- Math.sqrt(25)
(the built-in function Math.sqrt
returns the square-root of a number)
- Math.sqrt( 3*3 + 4*4 )
- Math.sqrt( Math.sqrt(16) )
- Math.sqrt( Math.abs(-16) )
(the built-in function Math.abs
returns the absolute value of a number)
Notice how, in the last three examples,
you compute an intermediate result,
and then pass that result as an input to another function
(the (outermost) Math.sqrt).
- (2pts) Java has function (method) which raises one number to another.
Look at the documentation for class Math,
and find it. (Hint: Alphabetically, it's between
“max” and “signum”;
the method summaries, closer to the top of the page,
are listed alphabetically.)
Write a java expression3 computing
220 (a.k.a. 1 Meg — a bit over a million),
using this function.
- (5pts)
What do each of the following Java snippets evaluate to?
(Give a value, or the error message produced.)
- 2+3)
- 2--5
- 2 - - 5 (note the spaces)
- Write “two minus negative five”
more clearly than either of the above attempts.
- 4 / 0
- Math.sqrt(-4.0)
- Math.log(0)
- Math.log(0) / Math.log(0)
- Math.log(-1)
- 10000000.0 (seven zeroes before the decimal point — ten million)
1But you are expected to finish homeworks over the weekend
and bring them to class on Monday morning;
the 17:00 deadline is there in case you run in to unexpected snags,
there is still a chance to come to office hours before the due-date.
↩
2You could even use BlueJ's editor,
if you like. ↩
3I'm asking for the expression,
not the numeric result. ↩
home—info—exams—lectures—labs—hws
Recipe—Laws—lies—syntax—java.lang docs—java.util docs