Lecture Notes, class 1 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.

Basic Terms.


Our First Program.

 class Welcome{
     public static void main( String [] args  ){
	   System.out.println("Welcome to csc211");
	   System.out.println("Good Luck and have a great quarter");
	 }
}
  

Getting the program to run.

If you will be working from home you will need to install some software.

Note getting the software to work can be a pain at first, so be patient. Note the software is available and works in the depaul labs so you will always have a place to practice and work on your homework.

See resource section of the course homepage


Basic Features.


Calculator Program

Write a program that gets two numbers from the user and displays to the console their sum, difference, product and ratio.

Since getting input is not as straight forward as producing output,lets assume the user entered the numbers 17 3.

See Calculator1.java


Some Terms


Arithmetic Operators

+     Addition
-     Subtraction
*     Multiplication
/     Division
%   Modulus

Integer division occurs if both operands are integer literals or variables of integer type.

Floating point division occurs if at least one of the operands is a floating point literal or variables of floating point type.

EXAMPLES.


  • Precedence rules for Arithmetic Operators

    EXAMPLES


    One way to get input into our programs

    Programming in Java involves writing classes, defining methods, using primitive data, using objects and using predefined classes that contain code already written for you to perform various tasks. When using a class you need to know the services( methods) that the class provides and the package that it resides in. A package is a group of related classes.

    One way to get input from the user is to use a class named...JOptionPane

    JOptionPane lives in package... javax.swing

    To use this class you must import it. Note: Classes that are part of java.lang do not need to be imported. They are automatically accessible.(System,String,Math etc...)

    See InputDialog.java and Calculator2.java