Tina Comston
Comp-111
Week 2
Franklin
University |
|
Week 2 |
|
|
Preparation
- Read Chapter 2 (sections 2.1 - 2.3, 2.8) in the COMP 111 Reading Guide.
- Read Appendix A in Big Java.
|
|
|
Guided
Learning Activity
|
|
|
Homework
YouTube video https://www.youtube.com/watch?v=jV3d3qUda8s This video describes variables and how they are defined.
- Problem 1
- Define a variable/identifier
- List the rules for naming a variable/identifier
- Problem 2
- Four primitive data types are used in Java:
- int - Integer or whole number (no decimals)
- double or floating point - number with decimals
- boolean - true or false
- char - a single character
- One class is introduced in these first sections
- String
- This is often thought of as primitive data because it is used so
often, but it is actually a class. When you create a String
variable, you are creating an object and with that objects comes
methods, actions that can be called to manipulate the data.
- For the different types of data listed in this problem, identify the most appropriate data type from those above.
- Problem 3
- When defining a variable/identifier the format is:
- dataType varName = literalValue;
- For example:
- Each
of the statements given contains a syntax error when defining a
variable/identifier. Identify the syntax error for each.
- Hint:
- you can create a class in BlueJ and copy the statements into the
class. Then compile to see the error identified by the compiler.
- Problem 4
- Create a class in BlueJ named Art.
- Remove all of the code inserted into the Art class by BlueJ.
- Copy the code from the problem and paste it into the Art class.
- Compile.
- Execute.
- Describe the output from the program.
- Problem 5
- Create a class in BlueJ named Cube.
- Remove all of the code inserted into the Cube class by BlueJ.
- Copy the code from the problem and paste it into the Cube class.
- Compile.
- Identify the syntax error and write it down, then correct.
- Continue this process until all the syntax errors have been identified and corrected.
- Copy the corrected code into the word document.
- Review the code and the output. There are 2 logic errors.
- Determine the errors.
- Correct.
- Compile and execute.
- Copy the corrected code into the word document.
|
|
|
Reflection
Paper
- Continue journaling your experiences for this course.
|
|
|
Lab
1
- Although Lab 1 is not due until Week 4, it's best not
to wait until Week 4 to begin working on this project. Read
through the instructions. Make sure you have a clear understanding of
what is needed. Take a look at the code that has been
provided.
|
|
|
|