Review of Previous Lesson

Slides:



Advertisements
Similar presentations
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Advertisements

Introduction to C++ Programming. A Simple Program: Print a Line of Text // My First C++ Program #include int main( ) { cout
Nested Loops. Nested loops Just as a selection structure can be nested within another selection structure (or within a loop), a loop can also be nested.
CS 106 Introduction to Computer Science I 02 / 18 / 2008 Instructor: Michael Eckmann.
Loops – While Loop Repetition Statements While Reading for this Lecture, L&L, 5.5.
CMT Programming Software Applications
CS 106 Introduction to Computer Science I 02 / 12 / 2007 Instructor: Michael Eckmann.
Introduction to Computers and Programming for Loops  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course. Introduction to.
Introduction to Computers and Programming Lecture 10: For Loops Professor: Evan Korth New York University.
©2004 Brooks/Cole Chapter 1: Getting Started Sections Covered: 1.1Introduction to Programming 1.2Constructing a Java Program 1.3The print() and println()
Loop variations do-while and for loops. Do-while loops Slight variation of while loops Instead of testing condition, then performing loop body, the loop.
CS 106 Introduction to Computer Science I 10 / 04 / 2006 Instructor: Michael Eckmann.
 2003 Prentice Hall, Inc. All rights reserved. Customized by Sana Odeh for the use of this class. 1 Introduction to Computers and Programming in JAVA.
© 2004 Pearson Addison-Wesley. All rights reserved5-1 Iterations/ Loops The while Statement Other Repetition Statements.
ECE122 L9: While loops March 1, 2007 ECE 122 Engineering Problem Solving with Java Lecture 9 While Loops.
Introducing Java.
1 2 2 Introduction to Java Applications Introduction Java application programming –Display messages –Obtain information from the user –Arithmetic.
Introduction to Java Thanks to Dan Lunney (SHS). Java Basics File names The “main” method Output to screen Escape Sequence – Special Characters format()
The string data type String. String (in general) A string is a sequence of characters enclosed between the double quotes "..." Example: Each character.
Loops: Handling Infinite Processes CS 21a: Introduction to Computing I First Semester,
Chapter 5 Loops.
Chapter 2: Java Fundamentals
27/05/ Iteration Loops Nested Loops & The Step Parameter.
A First Simple Program /* This is a simple Java program. Call this file "Example.java".*/ class Example { // Your program begins with a call to main().
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Output in Java Hello World!. Structure of a Java Program  All Java files in ICS3U1 have the following structure: class HelloWorld { }  Notice the open.
Can we talk?. In Hello World we already saw how to do Standard Output. You simply use the command line System.out.println(“text”); There are different.
Unix Environment Input Output 2  List Content (ls) ◦ ls (list current directory) ◦ ls –all (include hidden files/folders)  Make directory (mkdir) ◦
CSC141 Introduction to Computer Programming Teacher: AHMED MUMTAZ MUSTEHSAN Lecture - 6.
Chapter 2 topics Concept # on Java Subset Required for AP Exam print and println10. Testing of output is restricted to System.out.print and System.out.println.
Lab 01-2 Objectives:  Writing a Java program.  How to send output to the command line console.  Learn about escape sequences.  Learn how to compile,
Java iteration statements ● Iteration statements are statements which appear in the source code only once, but it execute many times. ● Such kind of statements.
Printing with for Loops To print a character multiple times, use a for loop. for (int j = 1; j
By Mr. Muhammad Pervez Akhtar
1 Data and Expressions Chapter 2 In PowerPoint, click on the speaker icon then the “play” button to hear audio narration.
CSC 110 – Intro to Computing - Programming
Chapter 2 1.What is the difference between print / println 2.What are String Literals 3.What are the Escape Characters for backslash, double quotataions,
Introduction to Computers and Programming Lecture 10: For Loops Professor: Evan Korth New York University.
Copyright 2010 by Pearson Education APCS Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
CS 106 Introduction to Computer Science I 02 / 15 / 2008 Instructor: Michael Eckmann.
Lecture 4 – Scanner & Style
CSC201: Computer Programming
Yanal Alahmad Java Workshop Yanal Alahmad
Chapter 2, Part I Introduction to C Programming
Loop Structures.
INPUT STATEMENTS GC 201.
CSS161: Fundamentals of Computing
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
MSIS 655 Advanced Business Applications Programming
Chapter 2 Create a Chapter 2 Workspace Create a Project called Notes
Escape sequences escape sequence: A special sequence of characters used to represent certain special characters in a string. \t Inserts a tab in the.
Nested Loops & The Step Parameter
Module 4 Loops and Repetition 2/1/2019 CSE 1321 Module 4.
Introduction to Java Brief history of Java Sample Java Program
Introduction to Java Applications
Review of Previous Lesson
CSE 142, Spring 2012 Building Java Programs Chapter 1
Review of Previous Lesson
Review of Previous Lesson
Review of Previous Lesson
Review of Previous Lesson
Output Manipulation.
Running a Java Program using Blue Jay.
Review of Previous Lesson
Review of Previous Lesson
Loops CGS3416 Spring 2019 Lecture 7.
Review of Previous Lesson
The Step Parameter & Nested For … To … Next loops
© A+ Computer Science - Basic Java © A+ Computer Science -
Chapter 2 part #1 C++ Program Structure
Presentation transcript:

Review of Previous Lesson 30/04/2019 Review of Previous Lesson State as many Vocabulary words and Learning Objectives that you remember from the last lesson as you can. Remember to grade yourself from 0 - 3.

30/04/2019 Loops / Iteration Nested for

Language Features and other Testable Topics 30/04/2019 Tested in the AP CS A Exam Notes Not tested in the AP CS A Exam, but potentially relevant/useful Escape Sequences \", \\, \n inside strings \’, \t, Input System.out.print 6 Control Statements for break

Language Features and other Testable Topics 30/04/2019 Notes: 6. User input is not included in the AP Java subset. There are many possible ways for supplying user input: e.g., by reading from a Scanner, reading from a stream (such as a file or a URL), or from a dialog box. There are advantages and disadvantages to the various approaches. The exam does not prescribe any one approach. Instead, if reading input is necessary, it will be indicated in a way similar to the following: double x = /* call to a method that reads a floating point number */; or double x = ...; // read user input

A nested for Iteration Loop 30/04/2019 A nested for Iteration Loop When you have one loop inside another. Think of the outer loop as a large cog driving a smaller cog which is the inner loop. Every time the larger cog revolves once (one repetition of the outer loop), the inner cog usually revolves more than once. As a solid real life example think of the second and minute hand. The minute hand would be the outer loop. The second hand would be the inner loop.

A nested for Iteration Loop 30/04/2019 A nested for Iteration Loop O u t e r L o p for(initialization; condition ; increment/decrement) { Outer body statement(s); Inner body statement(s); } I n e r L o p

30/04/2019 Nested for Example Output: for (int outerNum = 1; outerNum <= 4; outerNum ++) { System.out.println(outerNum); for (int innerNum = 1; innerNum <= 2; innerNum ++) { System.out.println(innerNum); } ? outerNum innerNum outerNum innerNum outerNum innerNum outerNum innerNum

break 30/04/2019 Used to come out of a loop instantly. Whenever a break statement is encountered inside a loop, the control directly comes out of loop and the loop gets terminated for rest of the iterations. It is used along with if statement, whenever used inside loop so that the loop gets terminated for a particular condition. When a break statement is used inside a nested loop, then only the inner loop gets terminated.

Escape Sequences 30/04/2019 Escape Sequence Description \" Inserts a double quote character in the text at this point. \\ Inserts a backslash character in the text at this point. \n Inserts a newline in the text at this point. \' Inserts a single quote character in the text at this point. \t Inserts a tab in the text at this point. Inside “ …. “, characters preceded by a backslash (\) which has a special meaning to the compiler. AP CS subset See next slide for an example.

Escape Sequences Example Program 30/04/2019 Escape Sequences Example Program public class EscapeSequencesExample{ public static void main(String[] args) { System.out.print("\"The \\Crazy\nProgrammer\""); } } Output: ?

print & println System.out.println(“…”) System.out.print(“….”) 30/04/2019 print & println System.out.println(“…”) As you know, prints the contents inside () to the console. What you may not have realised is this is done on the current line (last cursor position – see later), it does NOT move to the next line before printing. However, what it does do is move the ‘cursor’ to the next new line AFTER printing (so that any future printing is done on the next new line). System.out.print(“….”) Prints the contents inside () on the current line (last cursor position) in the same way as println, but what it doesn’t do, is move the ‘cursor’ to the next new line after printing. Therefore, any future printing appears on the same line as the last print. See next slide for an example.

println Vs print Example Program 30/04/2019 println Vs print Example Program public class PrintlnVsPrintExample { public static void main(String[] args) { System.out.println("test"); System.out.print("JA"); System.out.print("VA"); System.out.println("test2"); } } Output: ?

30/04/2019 Write your own programs: Write your own programs from “scratch”. Of course you should use previous programs for reference, but write your code from “scratch” (do not copy and paste).

Addition Table Specification: 30/04/2019 Write a program to display the sum of row and column numbers.

4/30/2019 Grade yourself Grade yourself on the vocabulary and learning objectives of the presentation.