Lecture 3
Announcements
- Read chapter 2 in the Java text this week, chapter 4 next week. (1-4 by
the time of the first exam.)
- Email assignments to 10801@mason.gmu.edu (if you are in labs 201-203) or
it10802@mason.gmu.edu (if you are in labs 204-206) and be sure to include
your full name and lab section number with each assignment. Email a copy of
the assignment to yourself as a backup until you are sure your graded is
recorded.
- Exam I: 2/20(bring a green scantron and 1 page of notes that you
have prepared by yourself.)
Topics for Today
- Review:
- compiler
- application
- applet
- byte code
- Fundamental Concepts Common to Javascript and Java: What is object
oriented programming (OOP)? What is a class? What is an object?
- Functions (Methods) - units of code that perform a specific task.
- Javascript:
function function_name (argumentlist)
{
//statements go here
}
- Java:
returntype function_name (argumentlist)
{
//statements go here
}
- Making a function happen is referred to as "calling" a function or "invoking" a method.
- Variables and Constants: A variable is a name that indicates a place in the computer's memory where information is stored.
Note that declaring variables in Java and Javascript differ:
- Java: int number; or int number=7;
- Javascript: var number or var number=7
- Operators: + (addition and concatenation), -, *, /, %, ++, --,=
==, <=, >=, !=, comments: // (one line only), /* ... */ (can
cover multiple lines, also called "block comments")
- statements: Java statements are terminated with semi-colons ;
Semi-colons are optional in Javascript unless you have more than
one statement per line.
- Compiling a Java application (hello world)
- Input/Output (I/O)
program 1
- Review Problems in Textbook, pp.40-41
- Practice! Using program 1 as a model, write a Java application to
convert 15 degrees Celcius to Fahrenheit. Use two variables: one to store
the temperature in Celcius, one to store the resulting temperature in
Fahrenheit. Your algorithm will be:
- Declare a variable and assign it 15
- Declare a second variable to store the result of the calculation
- Assign the second variable the result of the calculation (9/5)*
the first variable + 32.
- Print the result
Click here to
return to the IT 108 page
Copyright © 1999-2002 by Anne Marchant, all rights reserved.