Lecture Notes, class 2 for csc211.

Prepared by: Anthony Larrain

These notes serve as an outline to the lecture, they are not intended to be complete. You should be reading the assigned sections. During class I may include or omit certain topics.


Recap Class 1

Recap Class 1

Average Program

Write a Java program to compute the average of two integers. The integers will be entered using a dialog box. The answer will be displayed to the console .

Classes Used

Program Flow 1

Program Flow 2

Accumulates the sum as the integers are being read in.

  • Create a variable called sum initialized to 0.
  • Get first integer
  • Parse to an integer
  • Add it to sum and reassign current total to sum.
  • Get second integer
  • Parse to an integer
  • Add it to sum and reassign current total to sum.
  • <
  • Divide sum by 2.0
  • Display result


  • Some Useful Math Functions.

    The Math class provides us with some useful services (methods) that perform mathematical calculations. Here are a few, for more info Go To

    Examples