CS 101 - 10/2/12

Project 1 due tonight

Test 1 during Lecture on Thursday

20 multiple choice questions & 2 write code questions

variables and types

- int, float or double, char, String "hello", boolean

- World, Picture, Turtle

operators and assignments

arthimetic operators: ( ), * / %, + -

special ops: ++, --

/ does both integer and floating division

8/3 8.0/3.0

+ does addition and String Concatenation

8 + 2 "hello" + "there"

System.out.println ("The result is" + 8 + 2);

relational operators: = > >= < <=

looping: while loops

while ( <condition> )

{

<statements> ;

}

int x;

int y;

int z;

x = 3; // initialization

z = 0;

while ( x < 15 ) // condition

{

z = z + 1;

x = x + 5; // increment

}

Good Programming Style

good variable names

indentation

blank lines

uses of commenting

use of methods

Q 21, 22: Write code questions

Q21: "Write code that will...."

You must declare your variables!!!!

Q22: "Write a method called .... "

public static void methodName

( Turtle tParam, ..

===========================

x = 3;

y = 1;

z = 6;

while ( x < 6 )

{

z = y + z;

x = x + y;

}

x: 3 4 5 6

y: 1

z: 6 7 8 9

================

x = 1;

y = 2;

z = 3;

while ( x < 6 )

{

z = z + 4;

x = 1 + x;

}

x:1 2 3 4 5 6

y:2

z:3 7 11 15 19 23

Topic revision: r1 - 2012-10-02 - 15:50:32 - Main.troy
 
Copyright 2016 The Board of Trustees
of the University of Illinois.webmaster@cs.uic.edu
WISEST
Helping Women Faculty Advance
Funded by NSF