ITEC 320 Lecture 11 Application Part Deux Look Ahead.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

IT 325 OPERATING SYSTEM C programming language. Why use C instead of Java Intermediate-level language:  Low-level features like bit operations  High-level.
Q1 Review. Other News US News top CS Universities global-universities/computer- science?int=994b08.
ITEC 320 Lecture 12 Records. Intro to records Review Look_ahead(char,EOL); –What is this? –What does it allow us to do?
ITEC 320 Lecture 3 In-class coding / Arrays. Arrays Review Strings –Advantages / Disadvantages Input –What two methods are used? Conditionals Looping.
C++ Basics March 10th. A C++ program //if necessary include headers //#include void main() { //variable declaration //read values input from user //computation.
Intro Programming By Trevor Decker Team 1743 By Trevor Decker Team 1743.
Loops (Part 1) Computer Science Erwin High School Fall 2014.
Introduction to Computers and Programming Lecture 7:
ECE122 L11: For loops and Arrays March 8, 2007 ECE 122 Engineering Problem Solving with Java Lecture 11 For Loops and Arrays.
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
ECE122 L3: Expression Evaluation February 6, 2007 ECE 122 Engineering Problem Solving with Java Lecture 3 Expression Evaluation and Program Interaction.
C++ Basics CSci 107. A C++ program //include headers; these are modules that include functions that you may use in your //program; we will almost always.
Chapter 4: Control Structures II
Algorithms: Selected Exercises Goals Introduce the concept & basic properties of an algorithm.
How to use the CCS compiler with the serial port.
CIS Computer Programming Logic
Outlines Chapter 3 –Chapter 3 – Loops & Revision –Loops while do … while – revision 1.
ITEC 320 Lecture 5 Scope Exceptions. Scope / Exceptions Review Functions Procedures.
Java means Coffee Java Coffee Beans The name “JAVA” was taken from a cup of coffee.
Outline Character Strings Variables and Assignment Primitive Data Types Expressions Data Conversion Interactive Programs Graphics Applets Drawing Shapes.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
D. M. Akbar Hussain: Department of Software & Media Technology 1 Compiler is tool: which translate notations from one system to another, usually from source.
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 2: Variables & Data Types.
An Introduction to Java – Part 1 Dylan Boltz. What is Java?  An object-oriented programming language  Developed and released by Sun in 1995  Designed.
Chapter 5: Control Structures II J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design,
Chapter 5: Control Structures II
CSC 110 Using Python [Reading: chapter 1] CSC 110 B 1.
ITEC 320 Lecture 10 Examples. Review Strings –What types are there? –What are the differences? –What should you use where? Homework –Hardest part –Easiest.
Compiler Construction Dr. Naveed Ejaz Lecture 5. Lexical Analysis.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Chapter 5 Classes and Methods II Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
Chapter 2 Input, Variables and Data Types. JAVA Input JAVA input is not straightforward and is different depending on the JAVA environment that you are.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
© A+ Computer Science - A reference variable stores the memory address of an object. Monster fred = new Monster(); Monster sally.
Chapter 2: Fundamental Programming Structures in Java Adapted from MIT AITI Slides Control Structures.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 11: Pointers.
Keyboard and Screen I/O (Input/Output). Screen Output  System.out is an object that is part of the Java language. (Don’t worry yet about why there is.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
Chad’s C++ Tutorial Demo Outline. 1. What is C++? C++ is an object-oriented programming (OOP) language that is viewed by many as the best language for.
ITEC 320 Lecture 6 More on arrays / Strings. Arrays Review Scope Exceptions Arrays –Dynamic arrays How? Typed and anonymous.
SUMMARY OF CHAPTER 2: JAVA FUNDAMENTS STARTING OUT WITH JAVA: OBJECTS Parts of a Java Program.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Java String Methods - Codehs
Midterm preview.
Lecture 4 CS140 Dick Steflik. Reading Keyboard Input Import java.util.Scanner – A simple text scanner which can parse primitive types and strings using.
Basic concepts of C++ Presented by Prof. Satyajit De
Definition of the Programming Language CPRL
CIS3931 – Intro to JAVA Lecture Note Set 2 17-May-05.
Introduction to programming in java
Introduction to Computer Science / Procedural – 67130
Data Structures and Algorithms
Chapter 5: Control Structures II
CS1S467 GUI Programming Lecture 3 Variables 2.
Console input.
Introduction to Java Programming
An Introduction to Java – Part I, language basics
Building Java Programs
High Level Programming Languages
Your questions from last session
Fundamental Programming
Compiler Construction
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
C++ Basics CSci 107. A C++ program //include headers; these are modules that include functions that you may use in your //program; we will almost always.
LCC 6310 Computation as an Expressive Medium
Computer Science Club 1st November 2019.
COMPUTING.
Presentation transcript:

ITEC 320 Lecture 11 Application Part Deux Look Ahead

Applications / Look ahead Review In-class coding What did you learn?

Applications / Look ahead Outline Look ahead

Applications / Look ahead Input What are the problems with ADA input? What would need to be added to solve this?

Applications / Look ahead Example EOL: Boolean; c: Character; -- Caution: This example ignores EOL begin lookAhead(c, EOL); put(c); -- Output is 'H' lookAhead(c, EOL); put(c); -- Output is 'H' get(c); lookAhead(c, EOL); put(c); -- Output is 'e’ end example; Assumes input Hello

Applications / Look ahead Motivation Allows you to figure out how to read next bit of input lookAhead(c, EOL); -- Use get to input if Ada.Characters.Handling.Is_Digit(c) then Ada.Integer.Text_io.get(n); -- Get an integer else Ada.Text_io.get(c); -- Get a character end if;

Applications / Look ahead Motivation Allows multiple portions of code to access the same input Loop conditionals loop LookAhead(c, EOL); exit when is_Something(c); -- do something with c get(c); end loop; For example, when reading This can be used to help a compiler How else could this be accomplished?

Applications / Look ahead Issue What happens when you hit the end of line? Value returned depends on which way the wind blows EOL: Boolean; c: Character; begin loop lookAhead(c, EOL); if EOL then – End of line Ada.text_IO.Skip_line; else if is_digit(c) then -- do a numeric get else -- do a character get end if; end if; end loop;

Applications / Look ahead Review EOL false –Doesn’t advance input stream –Will return same value until some form of get is called EOL true –What it returns doesn’t matter

Applications / Look ahead Longer examples Web examples

Applications / Look ahead White space What is white space? Code to skip white space?

Applications / Look ahead Others Java –java.io.PushbackInputStream(InputStream) - constructs a stream that can be used to push back one byte –java.io.PushbackInputStream(InputStream, int size) - constructs a stream that can be used to push back size bytes –void unread(int b) pushes back the byte b which will be input again by the next read. Only one byte can be pushed back at a time. C++ –unget and putback C –ungetc

Applications / Look ahead Example Given a string, compute recursively (no loops) the number of times lowercase "hi" appears in the string.

Applications / Look ahead Summary Application coding Other languages