Lec4 Java Types Strings Input

Lec4 Java Types Strings Input - Lecture 4 Announcements...

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

View Full Document Right Arrow Icon
1 EE422C Data Structures Sarfraz Khurshid Lecture 4 9.7.10 Lecture 4 Announcements Assignment 1 out Today • flow charts • java types • strings (java.lang.String) EE322C 2 • console input (java.util.Scanner) Next time • methods and arrays Algorithmic Design Criteria An algorithm is a set of instructions for solving a given problem. It emphasizes the procedural aspects of a solution. A given problem may be solvable by various algorithms. A workable computer algorithm must be correct, complete, unambiguous and terminating. Your design will be checked for: • workability/correctness • completeness (at the level of abstraction presented) potential ambiguity EE322C 3 • termination • readability (by the grader) It can be in flowchart, pseudocode, recipe or some other variant format - as long as it makes sense and indicates that the student has a workable abstract PLAN for their program's logic. Grading the designs - worth 10 points total. • Give them a 0 if they do not turn one in. • Give them a 10 if they have a correct workable plan. • Take off up to 2 points for each of the 5 criteria above if you feel that their algorithm is deficient in that area. Flowchart Symbology 101-- Primitives Start/stop Process/ Decision Control flow EE322C 4 Task/action Input/output connector Three Proper Logic Constructs sequence iteration selection condition T F condition T F EE322C 5 . . . one or a block of statements grouped together Three Constructs - pseudocode style - sequence iteration selection 1. … 2. … 1. Repeat below steps while condition is true a) 1.If condition is true then EE322C 6 3…. b) … c) … end repeat 2. … 3. … else end if 2. … 3. … Use indentation to see the block structure
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 JAVA Control Statements Decision Making - selecting among alternative paths • Boolean values, variables and expressions (T/F) • Using if and if. ..else • Nested if Statements • Using switch Statements • Conditional Operators Iteration - bounded repetition of statement(s) Controlling the flow of the program’s logic EE322C 7 • Looping: while , do, and for • Nested loops • Using break and continue Nested Decision Logic Example EE322C 8 Income Tax Bracket Determination Logic Multi-way Branching Technique switch (expression) { case value1: // statements for this case break; case value2: expression is sometimes called a selector • case values must be literals •Can have as many cases as needed •break statements are optional EE322C 9 // statements for this case break; . . . default: // statements for default case } •default case is optional •Semantics are that a case is found based on matching the expression to the values in top to bottom order switch Statement Example // Select a transportation vehicle based on the # // of additional passengers Scanner sc = new Scanner(System. in); int numberOfPassengers = sc.nextInt(); switch (numberOfPassengers) { case 0: System. out.println("Take the Harley");
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 10/02/2010 for the course EE 322C taught by Professor Nettles during the Spring '08 term at University of Texas.

Page1 / 8

Lec4 Java Types Strings Input - Lecture 4 Announcements...

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