comp 14: miscellaneous :) may 30, 2000 nick vallidis

11
COMP 14: Miscellaneous :) May 30, 2000 Nick Vallidis

Post on 21-Dec-2015

215 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: COMP 14: Miscellaneous :) May 30, 2000 Nick Vallidis

COMP 14: Miscellaneous :)

May 30, 2000Nick Vallidis

Page 2: COMP 14: Miscellaneous :) May 30, 2000 Nick Vallidis

Announcements

I made some changes to the P2 assignment (only on hand-in and grading policy)

output printout -- It's ok to put the word document on the disk and not print it

Page 3: COMP 14: Miscellaneous :) May 30, 2000 Nick Vallidis

Review

What is control flow?What are the two types of

statements that modify the flow of control?

How does an if statement work?if (condition)

statement;

Page 4: COMP 14: Miscellaneous :) May 30, 2000 Nick Vallidis

Review (cont.)

How does an if-else statement work?

What if we want to put more than one statement in an if or if-else?

if (condition)

statement1;

else

statement2;

Page 5: COMP 14: Miscellaneous :) May 30, 2000 Nick Vallidis

Replacement

What do I mean when I type something like <variable>? I mean that the whole string "<variable>"

should be replaced by a variable name Examples from your homework assignment:

"<put your name here>" turns into "Nick Vallidis"

"<put date here>" turns into "May 30, 2000"

You'll see other people do this...

Page 6: COMP 14: Miscellaneous :) May 30, 2000 Nick Vallidis

Replacement

You'll also see this done with italicsExamples:

condition means use a boolean expression

statement means replace with an actual Java statement

Page 7: COMP 14: Miscellaneous :) May 30, 2000 Nick Vallidis

Indenting

Don't forget the way indenting works with if, if-else, and block statements

if:If (x > 255)

System.out.println("x is a big 'un.");

Indent here!

Page 8: COMP 14: Miscellaneous :) May 30, 2000 Nick Vallidis

Indenting

if-else:If (x > 255)

System.out.println("x is a big 'un.");

else

System.out.println("x ain't so big.");

Indents here!

Page 9: COMP 14: Miscellaneous :) May 30, 2000 Nick Vallidis

Indenting

Block statements:{

System.out.println("x is a big 'un.");

System.out.println("x ain't so big.");

}

Indents here!

Page 10: COMP 14: Miscellaneous :) May 30, 2000 Nick Vallidis

Indenting

This includes class definitions and main!Public class Birthday

{

public static void main(String[] args)

{

System.out.println("Hi!");

}

}Indents here!

Two indents here because we're inside 2 block statements

Page 11: COMP 14: Miscellaneous :) May 30, 2000 Nick Vallidis

Examples/Exercises

No homework tonight! (unless of course you'd like to read ahead. I mean you don't have to, but it would probably be a good idea. Sure, everyone deserves a break sometime, but you should be all energized since you just had a long weekend. You should be ready to work your heart out this week. But, hey, it's up to you.)