Presentation is loading. Please wait.

Presentation is loading. Please wait.

Haidong Xue Summer 2011, at GSU

Similar presentations


Presentation on theme: "Haidong Xue Summer 2011, at GSU"— Presentation transcript:

1 Haidong Xue Summer 2011, at GSU
Principles of Computer Programming (using Java) Chapter 8 More Control Structures Haidong Xue Summer 2011, at GSU

2 Content Quiz4 Assignment5 break and continue in if structure and loops
switch structure exceptions

3 Quiz4 1:50pm – 2:00pm

4 Assignment5 Answers Should we output the result in DatabaseLogic.java? Why?

5 break and continue Always exit or go back to the nearest structure
Example: BreakContinue.java

6 Labeled break and continue
Exit or go back to the structure with the label Example: LabeledBreakContinue

7 switch structure switch ( expression ) {
Integer (int, long ,short), char or enumeration expression switch ( expression ) { case constant-expression : statements default : statements } The value can be determined by the compiler

8 switch structure What are the statements that are executed?
The location of default Example: TestSwitch.java

9 Exceptions Type of exceptions: Throw a exception
Checked exceptions (thrown by throw statements) Unchecked exceptions (embedded exceptions) Throw a exception throw exception_object;

10 Exceptions Handling exceptions Examples: TestExceptions.java
try block catch (exception-type identifier) Examples: TestExceptions.java Improve previous codes

11 Assignment 6 Improve assignment 4, to solve the problem when the denominator is 0 Improve assignment 5, to solve the exceptions incurred by illegal inputs

12 Test 2 and Test 3 Test 2: Test 3: Using classes
Structures: if, while, do-while, for, switch Using arrays Using methods (how parameters are passed) Exceptions Test 3: Everything

13 Grading policy [50, 100] <=> B-, B, B+, A-, A
[0, 50] <=> F to C


Download ppt "Haidong Xue Summer 2011, at GSU"

Similar presentations


Ads by Google