Announcements review
This presentation is the property of its rightful owner.
Sponsored Links
1 / 12

Announcements & Review PowerPoint PPT Presentation


  • 57 Views
  • Uploaded on
  • Presentation posted in: General

Announcements Examples posted after lecture on schedule Discussion Section exercises on line before 9am Tuesdays Lab 2 Due Thursday 10pm. Last Time: Compilation Scaffolding print(): displays a value println(): displays a value and moves cursor to the next line.

Download Presentation

Announcements & Review

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Announcements review

Announcements

Examples posted after lecture on schedule

Discussion Section exercises on linebefore 9am Tuesdays

Lab 2 Due Thursday 10pm

Last Time:

Compilation

Scaffolding

print():

displays a value

println():

displays a value and moves cursor to the next line

Announcements & Review

Lecture 4: For Loops


Today

Today

More on Beauty

Analogy: Formatting Paragraphs

Sequencing

Analogy: a well constructed essay

Note on punctuation: end your statements

Repetition (i for iteration)

for (int i = 0; i < 10; i++) {

// your code here

}

Lecture 4: For Loops


Beauty

Beauty

/* Kathryn S McKinley

* September 2005

* file: Song.java - a few lines from a good song

* Song: All These Things That I’ve Done

* Band: The Killers, Album: Hot Fuss

*/

public class Song

{

public static void main (String [] args)

{

System.out.println(“You are going to bring yourself down”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“Yah yah, you got to help me out.”);

}

}

Lecture 4: For Loops


I m ugly

I’m Ugly

/* Kathryn S McKinley

* September 2005

* file: Song.java - a few lines from a good song

* Song: All These Things That I’ve Done

* Band: The Killers, Album: Hot Fuss

*/

public class Song

{

public static void main (String [] args)

{

System.out.println(“You are going to bring yourself down”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“Yah yah, you got to help me out.”);

}

}

Lecture 4: For Loops


Paragraphs

Paragraphs

// song lines

System.out.println(“You are going to bring yourself down”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“Yah yah, you got to help me out.”);

Lecture 4: For Loops


Paragraphs1

Paragraphs

// verse

System.out.println(“You are going to bring yourself down”);

//chorus

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

//verse

System.out.println(“Yah yah, you got to help me out.”);

Lecture 4: For Loops


Can we do better

Can we do better?

// verse

System.out.println(“You are going to bring yourself down.”);

//chorus

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

//verse

System.out.println(“Yah yah, you got to help me out.”);

Lecture 4: For Loops


Announcements review

Yes!

// verse

System.out.println(“You are going to bring yourself down.”);

//chorus

for (int i =0; i < 10; i++) {

System.out.println(“I’ve got soul, but I’m not a soldier. ”);

}

//verse

System.out.println(“Yah yah, you got to help me out.”);

Lecture 4: For Loops


For definite loop

For: Definite Loop

Three parts

for (i = 0; i < 99; i++) {

// loop body

}

  • Initialization

  • Test

  • Increment

Lecture 4: For Loops


For definite loop1

For: Definite Loop

Three parts

for (int i = 0; i < 99; i++) {

// loop body in here

}

  • Initialization - int i = 0;

    • one time only

  • Test - if i < 99 then execute body

    • every time

  • Increment - i++ add 1 to the value of I

    • every time

Lecture 4: For Loops


Bluej examples

BlueJ Examples

Lecture 4: For Loops


Questions

Questions?

Lecture 4: For Loops


  • Login