# Download 121 Discussion #1

Survey
Was this document useful for you?
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts

Mathematics of radio engineering wikipedia, lookup

Positional notation wikipedia, lookup

Location arithmetic wikipedia, lookup

Arithmetic wikipedia, lookup

Large numbers wikipedia, lookup

Addition wikipedia, lookup

Law of large numbers wikipedia, lookup

Elementary mathematics wikipedia, lookup

Transcript
```121 Discussion #1
Announcements:
Read 2.1-2.6 for Tuesday
OWL assignments now available: go to this URL
owl.oit.umass.edu/
Choose computer science. Login, with “login” = your student
number, password = “your last name”
1. Some general terminology questions..
What’s an operating system – give some of its functions
What does it mean to say that memory is volatile
What’s java bytecode
Is Java case-sensitive? And what does that mean?
2. Errors: remember the difference between compile-time, runtime, and logic errors. What are these?
a. multiplying two numbers when you meant to add them
b. dividing by zero
c. leaving off a semicolon at the end of a print statement
d. invoking this: system.out.println(“hi”);
3. Assignment statements
Recall the “cell” model of variable values
Try these examples
int num = 20;
num = 2*num; // does this make sense?
int a = 3;
int b = a + 5;
b = b + b;
b = b + b;
What value does b hold before and after each statement?
int pig; int dog; int cat;
cat = 1;
dog = 3;
pig = cat * cat;
cat = pig * pig;
What value does cat hold?
int hot; int cold;
hot = 3; cold = 5;
How can you swap the values of hot and cold?
4. The numbers 1,2,3,4 sit in the integer variables one,two,three,
and four. Use assignment statements to rotate them, so that the
same variables now hold 2,3,4,1.
5. Write a complete application that prints
+
++
+++
++++
6. There are other kinds of integer values: byte, short, int, long
There are two kinds of decimal (real) numbers float and double.
Create a variable called pi.. (and some others). Write a formula for
the area of a circle using java variables.
7. (harder)Use assignment to print the first 8 fibonacci numbers:
Sequence starts 1,1,2, and each successive number is the sum of
the two before it:
1,1,2,3,5,8,13,21
make this chart of triples:
1
1
2
etc
1
2
3
2
3
5
do the next five rows
draw arrows to show how the entries shift from row to row
Now write (or start writing) the assignment statements and print
statements that will produce the first eight Fibonacci numbers..
```