Decisions - Decisions Nothing is more difficult, and...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Decisions Nothing is more difficult, and therefore more precious, than to be able to decide. -- Napoleon Bonaparte I have always wished that my computer would be as easy to use as my telephone. My wish has come true. I no longer know how to use my telephone. --Bjarne Stroustrup (originator of C++ programming language) Review Exercise: Given a String variable myString which has already been initialized, declare a String variable part and assign it to contain the string consisting of the first 5 characters in myString . To Execute or not to Execute (a Statement), that is the question. A conditional statement allows us to choose which statement in our program will be executed next. Example:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Carry an umbrella The expression - the condition - inside the parentheses is either true or false. If it is true, then we will execute the next statement, which says to carry an umbrella. Java Example: if(grade > 95) { System.out.println("You made a high A!"); } Again the condition, or expression inside the parentheses, is a boolean value - it is either true or false. If it is true, the statement "You made a high A!" will be displayed in the console window. If it is false, then the next statement after the body of
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/24/2010 for the course C S 305j taught by Professor Staff during the Spring '08 term at University of Texas at Austin.

Page1 / 10

Decisions - Decisions Nothing is more difficult, and...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online