comp 14: miscellaneous :) may 30, 2000 nick vallidis
Post on 21-Dec-2015
215 views
TRANSCRIPT
COMP 14: Miscellaneous :)
May 30, 2000Nick 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
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;
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;
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...
Replacement
You'll also see this done with italicsExamples:
condition means use a boolean expression
statement means replace with an actual Java statement
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!
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!
Indenting
Block statements:{
System.out.println("x is a big 'un.");
System.out.println("x ain't so big.");
}
Indents here!
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
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.)