Announcements Review Last Time Announcements Examples posted after
- Slides: 12
Announcements & Review Last Time: Announcements Examples posted after lecture on schedule Discussion Section exercises on line before 9 am Tuesdays Lab 2 Due Thursday 10 pm – Compilation – Scaffolding – print(): displays a value – println(): displays a value and moves cursor to the next line Lecture 4: For Loops
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 /* Kathryn S Mc. Kinley * 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(“Yah yah, you got to help me out. ”); } } Lecture 4: For Loops
I’m Ugly /* Kathryn S Mc. Kinley * 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(“Yah yah, you got to help me out. ”); } } Lecture 4: For Loops
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(“Yah yah, you got to help me out. ”); Lecture 4: For Loops
Paragraphs // verse System. out. println(“You are going to bring yourself down”); //chorus System. out. println(“I’ve System. out. println(“I’ve got got got soul, soul, soul, but but but I’m I’m I’m not not not a a a a a soldier. //verse System. out. println(“Yah yah, you got to help me out. ”); Lecture 4: For Loops ”); ”); ”);
Can we do better? // verse System. out. println(“You are going to bring yourself down. ”); //chorus System. out. println(“I’ve System. out. println(“I’ve got got got soul, soul, soul, but but but I’m I’m I’m not not not a a a a a soldier. //verse System. out. println(“Yah yah, you got to help me out. ”); Lecture 4: For Loops ”); ”); ”);
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 Three parts for (i = 0; i < 99; i++) { // loop body } 1. Initialization 2. Test 3. Increment Lecture 4: For Loops
For: Definite Loop Three parts for (int i = 0; i < 99; i++) { // loop body in here } 1. Initialization - int i = 0; • one time only 2. Test - if i < 99 then execute body • every time 3. Increment - i++ add 1 to the value of I • every time Lecture 4: For Loops
Blue. J Examples Lecture 4: For Loops
Questions? Lecture 4: For Loops
- Errors discovered after an entry is posted
- After me after me after me
- John 14:1-3
- Signage posted at a handwashing station must include
- A food handler drops the end of a hose into a mop bucket
- Impulse physics examples
- Which column totals of a journal are posted?
- Front office organisation chart
- Look mom i posted it again
- Pvu market cap
- R/announcements
- David ritthaler
- What did beatty discover when he hit montag