In this reading, you will be introduced to the basics of the Java programming language. You’ll learn how to use the DrJava programming environment to do things such as perform calculations using numbers, print things to the screen, and create strings of text. You’ll also learn how to create and work with variables.
Don’t expect to fully understand everything on your first reading: you’ll likely need to work through the material several times before you get comfortable. I HIGHLY recommend that you keep DrJava open while reading so you can type in the code you read about; students who make this a habit tend to do better in the class.
Chapter 2 (pp. 14-35) from the course textbook.
Each student will be responsible for learning and demonstrating proficiency in the following objectives PRIOR to the class meeting. The reading quiz will test these objectives.
int
value to a double
(or vice versa), without the use of DrJava.The following objectives should be mastered by each student DURING and FOLLOWING the class session through active work and practice.
=
” operator and the “==
” operator in Java.These exercises are geared towards mastering the BASIC learning objectives listed above. You are expected to submit them before class and it is highly recommended that you complete them before attempting the reading quiz.
Textbook Problem: 2.11
Textbook Problem: 2.17 (please don’t use your real credit card number though!)
Use the DrJava Interactions Pane to calculate the area of a circle whose radius is 7. Store the result in a variable name “area” and then print it out. The equation for the area of a circle is π × r2. You may use either simplify π to 3.14 or use the Java’s built-in Math.PI
.
Copy and paste the text you entered as well as what was printed.
You are given the following sequence of Java statements.
int x = 8;
int y = 3;
String s1 = "I like the number " + x;
String s2 = "You like the number " + y;
String s3 = s1;
String s4;
If you were to execute this code, what would be stored in each of the variables (x
, y
, s1
, s2
, s3
, and s4
)?