COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand

Size: px
Start display at page:

Download "COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand"

Transcription

1 COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand

2 COSC 236 Web Site I hope to have a course web site up on Blackboard soon However, I am using the following site all semester to allow you to download course material: From this site you can click on the COSC-236 tab to download the PowerPoint lectures, the Quiz solutions and the Laboratory assignments. 2

3 Review of Quiz 02 Lecture 04 2/5/2014 3

4 Review of Quiz 02 Lecture 04 2/5/2014 4

5 Review of Quiz 02 Lecture 04 2/5/2014 5

6 Review of Quiz 02 Lecture 04 2/5/2014 6

7 Review of Quiz 02 PROBLEM: The tab character \n in output moves the cursor to the next tab stop on the output console. The default setting for tab stops on the DrJava console is 8 spaces. Two tab characters are required after the Gold Ring Lecture 04 2/5/2014 7

8 Review What is the output of the following println statements? System.out.println("\ta\tb\tc"); a b c System.out.println("\\\\"); \\ System.out.println("'"); ' System.out.println("\"\"\""); """ System.out.println("C:\nin\the downward spiral"); C: in he downward spiral 8

9 Review Write a println statement to produce the line of output: /\ //\\ System.out.println("\ /\\\ //\\\\\"); 9

10 Review What println statements will generate this output? This program prints a quote from the Gettysburg Address. "Four score and seven years ago, our 'fore fathers' brought forth on this continent a new nation. System.out.println("This program prints a"); System.out.println("quote from the Gettysburg Address."); System.out.println(); System.out.println("\"Four score and seven years ago,"); System.out.println("our 'fore fathers' brought forth on"); System.out.println("this continent a new nation.\""); 10

11 Review What println statements will generate this output? A "quoted" String is 'much' better if you learn the rules of "escape sequences." Also, "" represents an empty String. Don't forget: use \" instead of "! '' is not the same as System.out.println("A \"quoted\" String is"); System.out.println("'much' better if you learn"); System.out.println("the rules of \"escape sequences.\""); System.out.println(); System.out.println("Also, \"\" represents an empty String."); System.out.println("Don't forget: use \\\" instead of \"!"); System.out.println("'' is not the same as \""); 11

12 Review Where to place comments: at the top of each file (a "comment header") at the start of every method (seen in today s lecture) to explain complex pieces of code Comments are useful for: Understanding larger, more complex programs. Multiple programmers working together, who must understand each other's code. 12

13 Review Example of a wellcommented program: /* Suzy Student, CS 101, Fall 2019 This program prints lyrics about... something. */ public class BaWitDaBa { public static void main(string[] args) { // first verse System.out.println("Bawitdaba"); System.out.println("da bang a dang diggy diggy"); System.out.println(); // second verse System.out.println("diggy said the boogy"); System.out.println("said up jump the boogy"); 13

14 Chapter 1.3 (pp ) Program Errors (p. 24) Every programmer, no matter how experienced, spends a lot of their time finding errors bugs in their own programs! Some errors are found by the computer software (compiler errors and run time errors), but many errors are hidden from the computer and you must find them! Three Types of Errors Syntax Errors usually found by the compiler Logic Errors in which the program runs but does not do what it is supposed to do Logic Errors that are so bad that the program will not even run (runtime errors) 14

15 Chapter 1.3 (pp ) Syntax Errors (p. 24) The Java Compiler is easily confused by the simplest of grammar errors! (Look at the FIRST compiler error the following errors may actually be generated by the first error) A common, but difficult to find, error made by those new to Java is to have an incorrect file name (eg: Our program with class Hello MUST be stored in a file Hello.java). Common Syntax Errors (pp ) Incorrect punctuation (careful with every brace, bracket, parenthesis, simi-colon, etc.) Spelling Error (Java is case sensitive) Keyword Error (misspelling or using the wrong key word or using a key word by mistake as a variable) 15

16 Chapter 1.3 (pp ) Logic Errors (p. 28) Logic errors are errors in the logic of the programming that causes the program not to do what it is intended to do Logic errors can be avoided by writing carefully constructed code Logic errors usually do not show up in the compiler but rather at run time hence, they are also referred to as runtime errors Logic errors are also called bugs in the program 16

17 Chapter 1.4 Procedural Decomposition (pp ) Decomposition (pp ) One of the key contributions of CS-1 to your problem solving skills is the concept of decomposing complex problems into a series of simple ones This decomposition is the key to good problem solving Decomposition is also an important way to help avoid logic errors Decomposition is also allows you to check each small problem for possible security issues 17

18 Chapter 1.4 Procedural Decomposition (pp ) Procedural Decomposition is about problem solving (pp ) Procedural decomposition is taking a complex problem and breaking it down into an algorithm that consists of well-organized simple steps COSC-236 (CS-1) concentrates on procedural programming as opposed to object-oriented programming which is the subject of COSC-237 (CS-2) Procedural programming concentrates on the actions of solving a problem (Verb oriented) Object-oriented programming concentrates on decomposing the problem into a set of objects that must interact (Noun oriented) All computer languages support procedural programming and most modern languages support object-oriented programming JAVA supports both. 18

19 Chapter 1.4 Procedural Decomposition (pp ) Procedural vs Object-Oriented Problem Solving (pp ) BOTH are based on breaking problems down into an algorithm that consists of well-organized simple steps (procedural) or simple objects (object-oriented) CLASS is the key concept for object-oriented programming which is the subject of COSC-237 (CS-2) so we do little with classes in COSC- 236 (CS-1) METHODS and programming structures (loops, selection, etc.) are the key concepts for procedural programming and hence will be our main topics in COSC-236 (CS-1) 19

20 Procedural Algorithms (pp ) algorithm: A list of steps for solving a problem. Example algorithm: "Bake sugar cookies" Mix the dry ingredients. Cream the butter and sugar. Beat in the eggs. Stir in the dry ingredients. Set the oven temperature. Set the timer. Place the cookies into the oven. Allow the cookies to bake. Spread frosting and sprinkles onto the cookies. 20

21 Problems with algorithms (pp ) lack of structure: Many tiny steps; tough to remember. redundancy: Consider making a double batch... Mix the dry ingredients. Cream the butter and sugar. Beat in the eggs. Stir in the dry ingredients. Set the oven temperature. Set the timer. Place the first batch of cookies into the oven. Allow the cookies to bake. Set the timer. Place the second batch of cookies into the oven. Allow the cookies to bake. Mix ingredients for frosting. Spread frosting and sprinkles onto the cookies 21

22 Structured algorithms (pp ) structured algorithm: Split into coherent tasks. 1 Make the cookie batter. Mix the dry ingredients. Cream the butter and sugar. Beat in the eggs. Stir in the dry ingredients. 2 Bake the cookies. Set the oven temperature. Set the timer. Place the cookies into the oven. Allow the cookies to bake. 3 Add frosting and sprinkles. Mix the ingredients for the frosting. Spread frosting and sprinkles onto the cookies. 22

23 Removing redundancy (pp ) A well-structured algorithm can describe repeated tasks with less redundancy. 1 Make the cookie batter. Mix the dry ingredients.... 2a Bake the cookies (first batch). Set the oven temperature. Set the timer.... 2b Bake the cookies (second batch). 3 Decorate the cookies

24 A program with redundancy (pp ) public class BakeCookies { public static void main(string[] args) { System.out.println("Mix the dry ingredients."); System.out.println("Cream the butter and sugar."); System.out.println("Beat in the eggs."); System.out.println("Stir in the dry ingredients."); System.out.println("Set the oven temperature."); System.out.println("Set the timer."); System.out.println("Place a batch of cookies into the oven."); System.out.println("Allow the cookies to bake."); System.out.println("Set the oven temperature."); System.out.println("Set the timer."); System.out.println("Place a batch of cookies into the oven."); System.out.println("Allow the cookies to bake."); System.out.println("Mix ingredients for frosting."); System.out.println("Spread frosting and sprinkles."); 24

25 Static methods (pp ) static method: A named group of statements. denotes the structure of a program eliminates redundancy by code reuse procedural decomposition: dividing a problem into methods Writing a static method is like adding a new command to Java. class method A statement statement statement method B statement statement method C statement statement statement 25

26 Using static methods (pp ) 1. Design the algorithm. Look at the structure, and which commands are repeated. Decide what are the important overall tasks. 2. Declare (write down) the methods. Arrange statements into groups and give each group a name. 3. Call (run) the methods. The program's main method executes the other methods to perform the overall task. 26

27 Design of an algorithm (pp ) // This program displays a delicious recipe for baking cookies. public class BakeCookies2 { public static void main(string[] args) { // Step 1: Make the cake batter. System.out.println("Mix the dry ingredients."); System.out.println("Cream the butter and sugar."); System.out.println("Beat in the eggs."); System.out.println("Stir in the dry ingredients."); // Step 2a: Bake cookies (first batch). System.out.println("Set the oven temperature."); System.out.println("Set the timer."); System.out.println("Place a batch of cookies into the oven."); System.out.println("Allow the cookies to bake."); // Step 2b: Bake cookies (second batch). System.out.println("Set the oven temperature."); System.out.println("Set the timer."); System.out.println("Place a batch of cookies into the oven."); System.out.println("Allow the cookies to bake."); // Step 3: Decorate the cookies. System.out.println("Mix ingredients for frosting."); System.out.println("Spread frosting and sprinkles."); 27

28 Declaring a method (pp ) Syntax: Gives your method a name so it can be executed public static void name() { statement; statement;... statement; Example: public static void printwarning() { System.out.println("This product causes cancer"); System.out.println("in lab rats and humans."); 28

29 Calling a method (pp ) Syntax: name(); Executes the method's code You can call the same method many times if you like. Example: printwarning(); Output: This product causes cancer in lab rats and humans. 29

30 Program with static method (pp ) public class FreshPrince { public static void main(string[] args) { rap(); // Calling (running) the rap method System.out.println(); rap(); // Calling the rap method again // This method prints the lyrics to my favorite song. public static void rap() { System.out.println("Now this is the story all about how"); System.out.println("My life got flipped turned upside-down"); Output: Now this is the story all about how My life got flipped turned upside-down Now this is the story all about how My life got flipped turned upside-down 30

31 Final cookie program (pp ) // This program displays a delicious recipe for baking cookies. public class BakeCookies3 { public static void main(string[] args) { makebatter(); bake(); // 1st batch bake(); // 2nd batch decorate(); // Step 1: Make the cake batter. public static void makebatter() { System.out.println("Mix the dry ingredients."); System.out.println("Cream the butter and sugar."); System.out.println("Beat in the eggs."); System.out.println("Stir in the dry ingredients."); // Step 2: Bake a batch of cookies. public static void bake() { System.out.println("Set the oven temperature."); System.out.println("Set the timer."); System.out.println("Place a batch of cookies into the oven."); System.out.println("Allow the cookies to bake."); // Step 3: Decorate the cookies. public static void decorate() { System.out.println("Mix ingredients for frosting."); System.out.println("Spread frosting and sprinkles."); 31

32 Control flow (pp ) When a method is called, the program's execution... "jumps" into that method, executing its statements, then "jumps" back to the point where the method was called. public class MethodsExample { public static void main(string[] args) { message1(); message2(); public static void message1() { System.out.println("This is message1."); public static void message2() { System.out.println("This is message2."); message1(); System.out.println("Done with message2.");... System.out.println("Done with main."); public static void message1() { System.out.println("This is message1."); 32

33 Methods calling methods (pp ) public class MethodsExample { public static void main(string[] args) { message1(); message2(); System.out.println("Done with main."); public static void message1() { System.out.println("This is message1."); public static void message2() { System.out.println("This is message2."); message1(); System.out.println("Done with message2."); Output: This is message1. This is message2. This is message1. Done with message2. Done with main. 33

34 When to use methods (pp ) Place statements into a static method if: The statements are related structurally, and/or The statements are repeated. You should not create static methods for: An individual println statement. Only blank lines. (Put blank printlns in main.) Unrelated or weakly related statements. (Consider splitting them into two smaller methods.) 34

35 Example Runtime Error (pp ) A static procedure must not call itself This sets up an infinite loop resulting in a runtime error 35

36 Example Runtime Error (pp ) A more sophisticated infinite loop: This sets up an infinite loop resulting in a runtime error 36

37 Drawing complex figures with static methods Text Section 1.5 (pp )

38 Static methods question (pp ) Write a program to print these figures using methods. \ / \ / \ / \ / STOP \ / \ /

39 Development strategy (pp ) \ / \ / \ / \ / STOP \ / \ / First version (unstructured): Create an empty program and main method. Copy the expected output into it, surrounding each line with System.out.println syntax. Run it to verify the output

40 Program version ) (pp. public class Figures1 { public static void main(string[] args) { System.out.println(" "); System.out.println(" \"); System.out.println("\"); System.out.println("\\ /"); System.out.println(" \\ /"); System.out.println(); System.out.println("\\ /"); System.out.println(" \\ /"); System.out.println(" "); System.out.println(); System.out.println(" "); System.out.println(" \"); System.out.println("\"); System.out.println(" STOP "); System.out.println("\\ /"); System.out.println(" \\ /"); System.out.println(); System.out.println(" "); System.out.println(" \"); System.out.println("\"); System.out.println(" "); 40

41 Development strategy 2 (pp ) \ / \ / \ / \ / Second version (structured, with redundancy): Identify the structure of the output. Divide the main method into static methods based on this structure. STOP \ / \ /

42 Output structure (pp ) \ / \ / \ / \ / STOP \ / \ / The structure of the output: initial "egg" figure second "teacup" figure third "stop sign" figure fourth "hat" figure This structure can be represented by methods: egg teacup stopsign hat 42

43 Program version 2 (pp ) public class Figures2 { public static void main(string[] args) { egg(); teacup(); stopsign(); hat(); public static void egg() { System.out.println(" "); System.out.println(" \"); System.out.println("\"); System.out.println("\\ /"); System.out.println(" \\ /"); System.out.println(); public static void teacup() { System.out.println("\\ /"); System.out.println(" \\ /"); System.out.println(" "); System.out.println(); public static void stopsign() { System.out.println(" "); System.out.println(" \"); System.out.println("\"); System.out.println(" STOP "); System.out.println("\\ /"); System.out.println(" \\ /"); System.out.println(); public static void hat() { System.out.println(" "); System.out.println(" \"); System.out.println("\"); System.out.println(" "); 43

44 Development strategy 3 (pp ) \ / \ / \ / \ / Third version (structured, without redundancy): Identify redundancy in the output, and create methods to eliminate as much as possible. Add comments to the program. STOP \ / \ /

45 Output redundancy (pp ) \ / \ / \ / \ / STOP \ / \ / The redundancy in the output: egg top: reused on stop sign, hat egg bottom: reused on teacup, stop sign divider line: used on teacup, hat stop: Used in middle of stop sign This redundancy can be fixed by methods: eggtop eggbottom line (Not a separate method println) stop (Not a separate method println) 45

46 Program version 3 (pp ) // Suzy Student, CSE 138, Spring 2094 // Prints several figures, with methods for structure and redundancy. public class Figures3 { public static void main(string[] args) { egg(); teacup(); stopsign(); hat(); // Draws the top half of an an egg figure. public static void eggtop() { System.out.println(" "); System.out.println(" \"); System.out.println("\"); // Draws the bottom half of an egg figure. public static void eggbottom() { System.out.println("\\ /"); System.out.println(" \\ /"); // Draws a complete egg figure. public static void egg() { eggtop(); eggbottom(); System.out.println(); 46

47 Program version 3, cont'd. (pp ) // Draws a teacup figure. Public static void teacup() { eggbottom(); line(); System.out.println(); // Draws a stop sign figure. public static void stopsign() { eggtop(); System.out.println(" STOP "); eggbottom(); System.out.println(); // Draws a figure sort of like a hat. public static void hat() { eggtop(); line(); // Draws a line of dashes. public static void line() { System.out.println(" "); 47

48 Assignments Read Chapter 2.1 and 2.2 (pp ) before class on Wednesday Complete the Chapter 1 Laboratory assignment Submit your work as a Microsoft Word Document containing a report on each problem you solved in the laboratory. At a minimum, the report should include: Your first and last name The well-commented source code for each problem A screen shot of the DrJava screen showing successful compilation and run A complete output (you may need to copy and paste this into your Word document) your completed Word Document to Dr. Soderstrand at: Soderstrand@ieee.org Don t forget to take the Quiz before you leave today. 48

Building Java Programs

Building Java Programs Comments Building Java Programs Chapter 1 Lecture 1-2: Static Methods reading: 1.4-1.5 comment: A note written in source code by the programmer to describe or clarify the code. Comments are not executed

More information

Topic 3 static Methods and Structured Programming

Topic 3 static Methods and Structured Programming Topic 3 static Methods and Structured Programming "The cleaner and nicer the program, the faster it's going to run. And if it doesn't, it'll be easy to make it fast." -Joshua Bloch Based on slides by Marty

More information

Introduction to Computer Programming

Introduction to Computer Programming Introduction to Computer Programming Getting Started: An Introduction to Programming in Java What Is Programming? Computers cannot do all the wonderful things that we expect without instructions telling

More information

Building Java Programs

Building Java Programs Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading: 1.1-1.3 self-check: #1-14 exercises: #1-4 What is CSE? Computer Science Study of computation (information processing)

More information

Building Java Programs

Building Java Programs Building Java Programs Chapter 1 Lecture 1-2: Static Methods reading: 1.4-1.5 2 Recall: structure, syntax class: a program public class name { public static void main(string[] args) { statement; statement;...

More information

Building Java Programs Chapter 1

Building Java Programs Chapter 1 Building Java Programs Chapter 1 Introduction to Java Programming Copyright (c) Pearson 2013. All rights reserved. What is computer science? Computer Science The study of theoretical foundations of information

More information

CS 112 Introduction to Programming

CS 112 Introduction to Programming CS 112 Introduction to Programming (Spring 2012) Lecture #6: Static Methods and Decomposition Zhong Shao Department of Computer Science Yale University Office: 314 Watson http://flint.cs.yale.edu/cs112

More information

Recap: Structure of a Java program CS 112 Introduction to Programming. A Foundation for Programming Why Introduce Static Methods?

Recap: Structure of a Java program CS 112 Introduction to Programming. A Foundation for Programming Why Introduce Static Methods? Recap: Structure of a Java program CS 112 Introduction to Programming A class: - has a name, defined in a file with same name Convention we follow: capitalize each English word - starts with {, and ends

More information

Building Java Programs Chapter 1

Building Java Programs Chapter 1 Building Java Programs Chapter 1 Introduction to Java Programming Copyright (c) Pearson 2013. All rights reserved. The CS job market 160,000 140,000 120,000 100,000 80,000 60,000 PhD Master's Bachelor's

More information

Lecture 1: Basic Java Syntax

Lecture 1: Basic Java Syntax Lecture 1: Basic Java Syntax Building Java Programs: A Back to Basics Approach by Stuart Reges and Marty Stepp Copyright (c) Pearson 2013. All rights reserved. Java Terminology class: (a) A module or program

More information

Static Methods & Decomposition

Static Methods & Decomposition Static Methods & Decomposition Subset of the Supplement Lesson slides from: Building Java Programs, Chapter 1 by Stuart Reges and Marty Stepp (http://www.buildingjavaprograms.com/ ) Warm Up Questions What

More information

Entering the world of Javatar

Entering the world of Javatar Entering the world of Javatar Subset of the Supplement Lesson slides from: Building Java Programs by Stuart Reges and Marty Stepp (http://www.buildingjavaprograms.com/ ) Compiling/running programs 1. Write

More information

Building Java Programs

Building Java Programs Building Java Programs Chapter 1 Lecture 2: Static Methods reading: 1.4-1.5 (Slides adapted from Stuart Reges, Hélène Martin, and Marty Stepp) 2 Recall: structure, syntax class: a program public class

More information

CSE 142, Summer 2015

CSE 142, Summer 2015 CSE 142, Summer 2015 Lecture 2: Static Methods Expressions reading: 1.4 2.1 The Mechanical Turk 2 Escape Characters System.out.println( ab\ \\\\\\/\td ); Output: ab \\\/ d 3 Algorithms algorithm: A list

More information

CSc 110, Autumn Lecture 2: Functions

CSc 110, Autumn Lecture 2: Functions CSc 110, Autumn 2017 Lecture 2: Functions Escape sequences escape sequence: A special sequence of characters used to represent certain special characters in a string. \t tab character \n new line character

More information

CSc 110, Spring Lecture 2: Functions. Adapted from slides by Marty Stepp and Stuart Reges

CSc 110, Spring Lecture 2: Functions. Adapted from slides by Marty Stepp and Stuart Reges CSc 110, Spring 2017 Lecture 2: Functions Adapted from slides by Marty Stepp and Stuart Reges 1 Review From last lecture: print, strings, escape sequences. What is the output of the following statement?

More information

CSE 142, Summer 2014

CSE 142, Summer 2014 CSE 142, Summer 2014 Lecture 2: Static Methods Expressions reading: 1.4 2.1 Algorithms algorithm: A list of steps for solving a problem. Example algorithm: "Bake sugar cookies" Mix the dry ingredients.

More information

COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand

COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand COSC 236 Web Site You will always find the course material at: http://www.class-notes.us or http://www.class-notes.info or http://www.lecture-notes.tripod.com

More information

Building Java Programs

Building Java Programs Building Java Programs Chapter 1: Introduction to Java Programming These lecture notes are copyright (C) Marty Stepp and Stuart Reges, 2007. They may not be rehosted, sold, or modified without expressed

More information

Procedural decomposition using static methods

Procedural decomposition using static methods Algorithms Procedural decomposition using static methods Recall: An algorithm is a list of steps for solving a problem. What is the algorithm to bake sugar cookies? 1 2 The Bake sugar cookies algorithm

More information

clicker question Comments Using comments Topic 3 static Methods and Structured Programming

clicker question Comments Using comments Topic 3 static Methods and Structured Programming Topic 3 static Methods and Structured Programming "The cleaner and nicer the program, the faster it's going to run. And if it doesn't, it'll be easy to make it fast." -Joshua Bloch clicker question What

More information

Building Java Programs. Chapter 1: Introduction to Java Programming

Building Java Programs. Chapter 1: Introduction to Java Programming Building Java Programs Chapter 1: Introduction to Java Programming Lecture outline Introduction Syllabus and policies What is computer science Programs and programming languages Basic Java programs Output

More information

CSE 142. Lecture 1 Course Introduction; Basic Java. Portions Copyright 2008 by Pearson Education

CSE 142. Lecture 1 Course Introduction; Basic Java. Portions Copyright 2008 by Pearson Education CSE 142 Lecture 1 Course Introduction; Basic Java Welcome Today: Course mechanics A little about computer science & engineering (CSE) And how this course relates Java programs that print text 2 Handouts

More information

Building Java Programs. Introduction to Java Programming

Building Java Programs. Introduction to Java Programming Building Java Programs Introduction to Java Programming 1 What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed for easy Web/Internet

More information

CSE 201 Java Programming I. Smart Coding School website:

CSE 201 Java Programming I. Smart Coding School website: CSE 201 Java Programming I Smart Coding School website: http://www.smartcodingschool.com Definition: A named group of statements public static void methodname() { statements Usage: 1. denotes the structure

More information

Welcome to CSE 142! Zorah Fung University of Washington, Spring Building Java Programs Chapter 1 Lecture 1: Introduction; Basic Java Programs

Welcome to CSE 142! Zorah Fung University of Washington, Spring Building Java Programs Chapter 1 Lecture 1: Introduction; Basic Java Programs Welcome to CSE 142! Zorah Fung University of Washington, Spring 2015 Building Java Programs Chapter 1 Lecture 1: Introduction; Basic Java Programs reading: 1.1-1.3 1 What is computer science? computers?

More information

Welcome to CSE 142! Whitaker Brand. University of Washington, Winter 2018

Welcome to CSE 142! Whitaker Brand. University of Washington, Winter 2018 Welcome to CSE 142! Whitaker Brand University of Washington, Winter 2018 1 What is computer science? computers? science? programming? late lonely nights in front of the computer? ALGORITHMIC THINKING al

More information

Building Java Programs. Introduction to Programming and Simple Java Programs

Building Java Programs. Introduction to Programming and Simple Java Programs Building Java Programs Introduction to Programming and Simple Java Programs 1 A simple Java program public class Hello { public static void main(string[] args) { System.out.println("Hello, world!"); code

More information

COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand

COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand COSC 236 Web Site I have decided to keep this site for the whole semester I still hope to have blackboard up and running, but you

More information

Introduction to Java. Java Programs Classes, Methods, and Statements Comments Strings Escape Sequences Identifiers Keywords

Introduction to Java. Java Programs Classes, Methods, and Statements Comments Strings Escape Sequences Identifiers Keywords Introduction to Java Java Programs Classes, Methods, and Statements Comments Strings Escape Sequences Identifiers Keywords Program Errors Syntax Runtime Logic Procedural Decomposition Methods Flow of Control

More information

CS 112 Introduction to Programming

CS 112 Introduction to Programming CS 112 Introduction to Programming Lecture #2: Java Program Structure Yang (Richard) Yang Computer Science Department Yale University 308A Watson, Phone: 432-6400 Email: yry@cs.yale.edu 2 1 Outline q Admin.

More information

COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand

COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand COSC 236 Web Site You will always find the course material at: http://www.class-notes.us From this site you can click on the COSC-236

More information

CS 112 Introduction to Programming

CS 112 Introduction to Programming CS 112 Introduction to Programming Java Primitive Data Types; Arithmetic Expressions Yang (Richard) Yang Computer Science Department Yale University 308A Watson, Phone: 432-6400 Email: yry@cs.yale.edu

More information

Admin. CS 112 Introduction to Programming. Recap: Java Static Methods. Recap: Decomposition Example. Recap: Static Method Example

Admin. CS 112 Introduction to Programming. Recap: Java Static Methods. Recap: Decomposition Example. Recap: Static Method Example Admin CS 112 Introduction to Programming q Programming assignment 2 to be posted tonight Java Primitive Data Types; Arithmetic Expressions Yang (Richard) Yang Computer Science Department Yale University

More information

Creating a Program in JCreator. JCreator is then used to create our program. But the first step is to create a new file.

Creating a Program in JCreator. JCreator is then used to create our program. But the first step is to create a new file. First Program (02) Creating a Java program and understanding the basic concepts. Creating a Program in JCreator It is usually a good idea to create a folder where you re going to save your Java programs.

More information

COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand

COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand COSC 236 Web Site You will always find the course material at: http://www.class-notes.us From this site you can click on the COSC-236

More information

Java Programming. What is a program? Programs Recipes. Programs as Recipes 8/16/12. Pancakes In one bowl. mix: 1½ cup flour

Java Programming. What is a program? Programs Recipes. Programs as Recipes 8/16/12. Pancakes In one bowl. mix: 1½ cup flour What is a program? Java Programming CS 160, Fall Semester 2012 TOPICS Computer Programs Using Eclipse Program Program Components Definition: a sequence of instructions telling a computer what to do Analogy:

More information

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG 1 Notice Reading Assignment Chapter 1: Introduction to Java Programming Homework 1 It is due this coming Sunday

More information

Lab # 2. For today s lab:

Lab # 2. For today s lab: 1 ITI 1120 Lab # 2 Contributors: G. Arbez, M. Eid, D. Inkpen, A. Williams, D. Amyot 1 For today s lab: Go the course webpage Follow the links to the lab notes for Lab 2. Save all the java programs you

More information

COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand

COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand COSC 236 Web Site You will always find the course material at: http://www.class-notes.us From this site you can click on the COSC-236

More information

Getting Started With Java

Getting Started With Java Getting Started With Java Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: www.sisoft.in Email:info@sisoft.in Phone: +91-9999-283-283 Java - Overview

More information

COMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2015

COMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2015 COMP-202: Foundations of Programming Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2015 Assignment Due Date Assignment 1 is now due on Tuesday, Jan 20 th, 11:59pm. Quiz 1 is

More information

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 8: SEP. 29TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 8: SEP. 29TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 8: SEP. 29TH INSTRUCTOR: JIAYIN WANG 1 Notice Prepare the Weekly Quiz The weekly quiz is for the knowledge we learned in the previous week (both the

More information

Java Programming. What is a program? Programs as Recipes. Programs Recipes 8/20/15. Pancakes In one bowl

Java Programming. What is a program? Programs as Recipes. Programs Recipes 8/20/15. Pancakes In one bowl What is a program? Java Programming CS 160, Fall Semester 2012 TOPICS Computer Programs Using Eclipse Program Program Components Definition: a sequence of instructions telling a computer what to do Analogy:

More information

COMP-202: Foundations of Programming. Lecture 4: Flow Control Loops Sandeep Manjanna, Summer 2015

COMP-202: Foundations of Programming. Lecture 4: Flow Control Loops Sandeep Manjanna, Summer 2015 COMP-202: Foundations of Programming Lecture 4: Flow Control Loops Sandeep Manjanna, Summer 2015 Announcements Check the calendar on the course webpage regularly for updates on tutorials and office hours.

More information

The CS job market. Building Java Programs Chapter 1. Programming languages. What is programming? Introduction to Java Programming

The CS job market. Building Java Programs Chapter 1. Programming languages. What is programming? Introduction to Java Programming The CS job market 160,000 Buildig Java Programs Chapter 1 Itroductio to Java Programmig 140,000 120,000 100,000 80,000 60,000 40,000 PhD Master's Bachelor's Projected Job Opeigs 20,000 Copyright (c) Pearso

More information

CIS 110: Introduction to Computer Programming. Lecture 2 Decomposition and Static Methods ( 1.4)

CIS 110: Introduction to Computer Programming. Lecture 2 Decomposition and Static Methods ( 1.4) CIS 110: Introduction to Computer Programming Lecture 2 Decomposition and Static Methods ( 1.4) Outline Structure and redundancy in algorithms Static methods Procedural decomposition 9/16/2011 CIS 110

More information

Week 2: Data and Output

Week 2: Data and Output CS 170 Java Programming 1 Week 2: Data and Output Learning to speak Java Types, Values and Variables Output Objects and Methods What s the Plan? Topic I: A little review IPO, hardware, software and Java

More information

COMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2016

COMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2016 COMP-202: Foundations of Programming Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2016 Learn about cutting-edge research over lunch with cool profs January 18-22, 2015 11:30

More information

Building Java Programs

Building Java Programs Building Java Programs Chapter 3 Lecture 5: Parameters and Scope reading: 3.1 i's scope Scope scope: The part of a program where a variable exists. From its declaration to the end of the { braces A variable

More information

Building Java Programs

Building Java Programs Building Java Programs Chapter 3 Lecture 3-1: Parameters reading: 3.1 self-check: #1-6 exercises: #1-3 videos: Ch. 3 #1 Redundant recipes Recipe for baking 20 cookies: Mix the following ingredients in

More information

CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics. COMP-202 Unit 1: Introduction

CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics. COMP-202 Unit 1: Introduction CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics COMP-202 Unit 1: Introduction Assignment 1 Assignment 1 posted on WebCt and course website. It is due September 22nd

More information

Building Java Programs

Building Java Programs Building Java Programs Chapter 3 Lecture 3-1: Parameters reading: 3.1 (I think this is a made up language like Visual Basic but not quite.) 2 Promoting reuse Programmers build increasingly complex applications

More information

CS 152: Data Structures with Java Hello World with the IntelliJ IDE

CS 152: Data Structures with Java Hello World with the IntelliJ IDE CS 152: Data Structures with Java Hello World with the IntelliJ IDE Instructor: Joel Castellanos e-mail: joel.unm.edu Web: http://cs.unm.edu/~joel/ Office: Electrical and Computer Engineering building

More information

Programming in Java Prof. Debasis Samanta Department of Computer Science Engineering Indian Institute of Technology, Kharagpur

Programming in Java Prof. Debasis Samanta Department of Computer Science Engineering Indian Institute of Technology, Kharagpur Programming in Java Prof. Debasis Samanta Department of Computer Science Engineering Indian Institute of Technology, Kharagpur Lecture 04 Demonstration 1 So, we have learned about how to run Java programs

More information

CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics. COMP-202 Unit 1: Introduction

CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics. COMP-202 Unit 1: Introduction CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics COMP-202 Unit 1: Introduction Announcements Did you miss the first lecture? Come talk to me after class. If you want

More information

Programming with Java

Programming with Java Programming with Java Variables and Output Statement Lecture 03 First stage Software Engineering Dep. Saman M. Omer 2017-2018 Objectives ü Declare and assign values to variable ü How to use eclipse ü What

More information

COMP-202: Foundations of Programming. Lecture 2: Variables, and Data Types Sandeep Manjanna, Summer 2015

COMP-202: Foundations of Programming. Lecture 2: Variables, and Data Types Sandeep Manjanna, Summer 2015 COMP-202: Foundations of Programming Lecture 2: Variables, and Data Types Sandeep Manjanna, Summer 2015 Announcements Midterm Exams on 4 th of June (12:35 14:35) Room allocation will be announced soon

More information

List of Slides 1 Title 2 Chapter 2: Sequential execution and program errors 3 Chapter aims 4 Section 2: Example:Hello world 5 Aim 6 Class: programs ar

List of Slides 1 Title 2 Chapter 2: Sequential execution and program errors 3 Chapter aims 4 Section 2: Example:Hello world 5 Aim 6 Class: programs ar List of Slides 1 Title 2 Chapter 2: Sequential execution and program errors 3 Chapter aims 4 Section 2: Example:Hello world 5 Aim 6 Class: programs are divided into classes 7 Class: public class 8 Class:

More information

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA 1 TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson, and instructor materials prepared

More information

COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand

COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand COSC 236 Web Site You will always find the course material at: http://www.class-notes.us or http://www.class-notes.info or http://www.lecture-notes.tripod.com

More information

Class 1: Homework. Intro to Computer Science CSCI-UA.0101 New York University Courant Institute of Mathematical Sciences Fall 2017

Class 1: Homework. Intro to Computer Science CSCI-UA.0101 New York University Courant Institute of Mathematical Sciences Fall 2017 Intro to Computer Science CSCI-UA.0101 New York University Courant Institute of Mathematical Sciences Fall 2017 1 1. Please obtain a copy of Introduction to Java Programming, 11th (or 10th) Edition, Brief

More information

COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand

COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand COSC 236 Web Site You will always find the course material at: http://www.class-notes.us or http://www.class-notes.info or http://www.lecture-notes.tripod.com

More information

CS106A, Stanford Handout #25. Methods 2

CS106A, Stanford Handout #25. Methods 2 CS106A, Stanford Handout #25 Fall, 2004-05 Nick Parlante Methods 2 System.out.println() Console System.out is a standard system object. It implements a println() method that takes a String argument and

More information

17 Hello world 18 Type: String: literal 19 Standard API: System: out.println() 20 Hello world 21 Statement 22 Statement: simple statements are ended w

17 Hello world 18 Type: String: literal 19 Standard API: System: out.println() 20 Hello world 21 Statement 22 Statement: simple statements are ended w List of Slides 1 Title 2 Chapter 2: Sequential execution and program errors 3 Chapter aims 4 Section 2: Example:Hello world 5 Aim 6 Class: programs are divided into classes 7 Class: public class 8 Class:

More information

Introduction to Data Structures

Introduction to Data Structures 15-121 Introduction to Data Structures Lecture #1 Introduction 28 August 2019 Margaret Reid-Miller Today Course Administration Overview of Course A (very basic) Java introduction Course website: www.cs.cmu.edu/~mrmiller/15-121

More information

Outline. CIS 110: Introduction to Computer Programming. What is Computer Science? What is computer programming? What is computer science?

Outline. CIS 110: Introduction to Computer Programming. What is Computer Science? What is computer programming? What is computer science? Outline CIS 110: Introduction to Computer Programming Lecture 1 An introduction of an introduction ( 1.1 1.3)* 1. What is computer science and computer programming? 2. Introductions and logistics 3. The

More information

CS 170 Java Programming 1. Week 5: Procedures and Functions

CS 170 Java Programming 1. Week 5: Procedures and Functions CS 170 Java Programming 1 Week 5: Procedures and Functions What s the Plan? Topic 1: More on graphical objects Creating your own custom Turtle types Introducing media, pictures and sounds Topic 2: Decomposition:

More information

CSE 142 Su01 Final Exam Sample Solution page 1 of 7

CSE 142 Su01 Final Exam Sample Solution page 1 of 7 CSE 142 Su01 Final Exam Sample Solution page 1 of 7 Answer all of the following questions. READ EACH QUESTION CAREFULLY. Answer each question in the space provided on these pages. Budget your time so you

More information

Getting started with Java

Getting started with Java Getting started with Java Magic Lines public class MagicLines { public static void main(string[] args) { } } Comments Comments are lines in your code that get ignored during execution. Good for leaving

More information

Everyday Algorithms. Algorithms and Introduction to Programming. bake a cake. start. mix sugar and butter. stir in 2 eggs. stir in flour.

Everyday Algorithms. Algorithms and Introduction to Programming. bake a cake. start. mix sugar and butter. stir in 2 eggs. stir in flour. Everyday Algorithms start bake a cake mix sugar and butter stir in 2 eggs stir in flour put in pans bake for 10 mins fork test clear? no yes end Adapted from Fluency with Information Technology, Lawrence

More information

Wentworth Institute of Technology. Engineering & Technology WIT COMP1000. Java Basics

Wentworth Institute of Technology. Engineering & Technology WIT COMP1000. Java Basics WIT COMP1000 Java Basics Java Origins Java was developed by James Gosling at Sun Microsystems in the early 1990s It was derived largely from the C++ programming language with several enhancements Java

More information

Java Programming Fundamentals - Day Instructor: Jason Yoon Website:

Java Programming Fundamentals - Day Instructor: Jason Yoon Website: Java Programming Fundamentals - Day 1 07.09.2016 Instructor: Jason Yoon Website: http://mryoon.weebly.com Quick Advice Before We Get Started Java is not the same as javascript! Don t get them confused

More information

Java Basics. Object Orientated Programming in Java. Benjamin Kenwright

Java Basics. Object Orientated Programming in Java. Benjamin Kenwright Java Basics Object Orientated Programming in Java Benjamin Kenwright Outline Essential Java Concepts Syntax, Grammar, Formatting, Introduce Object-Orientated Concepts Encapsulation, Abstract Data, OO Languages,

More information

Repetition with for loops

Repetition with for loops Repetition with for loops So far, when we wanted to perform a task multiple times, we have written redundant code: System.out.println( Building Java Programs ); // print 5 blank lines System.out.println(

More information

Get JAVA. I will just tell you what I did (on January 10, 2017). I went to:

Get JAVA. I will just tell you what I did (on January 10, 2017). I went to: Get JAVA To compile programs you need the JDK (Java Development Kit). To RUN programs you need the JRE (Java Runtime Environment). This download will get BOTH of them, so that you will be able to both

More information

Lecture Notes for CS 150 Fall 2009; Version 0.5

Lecture Notes for CS 150 Fall 2009; Version 0.5 for CS 150 Fall 2009; Version 0.5 Draft! Do not distribute without prior permission. Copyright 2001-2009 by Mark Holliday Comments, corrections, and other feedback appreciated holliday@email.wcu.edu Chapter

More information

Lesson 1A - First Java Program HELLO WORLD With DEBUGGING examples. By John B. Owen All rights reserved 2011, revised 2015

Lesson 1A - First Java Program HELLO WORLD With DEBUGGING examples. By John B. Owen All rights reserved 2011, revised 2015 Lesson 1A - First Java Program HELLO WORLD With DEBUGGING examples By John B. Owen All rights reserved 2011, revised 2015 Table of Contents Objectives Hello World Lesson Sequence Compile Errors Lexical

More information

C02: Overview of Software Development and Java

C02: Overview of Software Development and Java CISC 3120 C02: Overview of Software Development and Java Hui Chen Department of Computer & Information Science CUNY Brooklyn College 08/31/2017 CUNY Brooklyn College 1 Outline Recap and issues Brief introduction

More information

CS 177 Recitation. Week 1 Intro to Java

CS 177 Recitation. Week 1 Intro to Java CS 177 Recitation Week 1 Intro to Java Questions? Computers Computers can do really complex stuff. How? By manipulating data according to lists of instructions. Fundamentally, this is all that a computer

More information

Project #1 rev 2 Computer Science 2334 Fall 2013 This project is individual work. Each student must complete this assignment independently.

Project #1 rev 2 Computer Science 2334 Fall 2013 This project is individual work. Each student must complete this assignment independently. Project #1 rev 2 Computer Science 2334 Fall 2013 This project is individual work. Each student must complete this assignment independently. User Request: Create a simple magazine data system. Milestones:

More information

CS Week 2. Jim Williams, PhD

CS Week 2. Jim Williams, PhD CS 200 - Week 2 Jim Williams, PhD Society of Women Engineers "Not just for women and not just for engineers; all students are welcome. We are especially looking for more computer science students!" - Emile

More information

Basic Programming Language Syntax

Basic Programming Language Syntax Java Created in 1990 by Sun Microsystems. Free compiler from Sun, commercial from many vendors. We use free (Sun) Java on UNIX. Compiling and Interpreting...are processes of translating a high-level programming

More information

COMPUTATIONAL THINKING

COMPUTATIONAL THINKING Computational Concepts sequence loops parallelism events conditionals operators variables lists COMPUTATIONAL THINKING PROGRAMMING AS PROBLEM SOLVING Computational Practices incremental/iterative testing/debugging

More information

QUIZ. What is wrong with this code that uses default arguments?

QUIZ. What is wrong with this code that uses default arguments? QUIZ What is wrong with this code that uses default arguments? Solution The value of the default argument should be placed in either declaration or definition, not both! QUIZ What is wrong with this code

More information

ALICE: An introduction to progamming

ALICE: An introduction to progamming ALICE: An introduction to progamming What is Computer Science? Computer Science Do you know the difference between ICT and Computer Science? Any suggestions as to what jobs you could do if you were a Computer

More information

SDKs - Eclipse. SENG 403, Tutorial 2

SDKs - Eclipse. SENG 403, Tutorial 2 SDKs - SENG 403, Tutorial 2 AGENDA - SDK Basics - - How to create Project - How to create a Class - Run Program - Debug Program SDK Basics Software Development Kit is a set of software development tools

More information

Lecture 7. Instructor: Craig Duckett OUTPUT

Lecture 7. Instructor: Craig Duckett OUTPUT Lecture 7 Instructor: Craig Duckett OUTPUT Lecture 7 Announcements ASSIGNMENT 2 is due LECTURE 8 NEXT LECTURE uploaded to StudentTracker by midnight Assignment 2!!! Assignment Dates (By Due Date) Assignment

More information

Chapter 29B: More about Strings Bradley Kjell (Revised 06/12/2008)

Chapter 29B: More about Strings Bradley Kjell (Revised 06/12/2008) Chapter 29B: More about Strings Bradley Kjell (Revised 06/12/2008) String objects are frequently used in programs. This chapter provides extra practice in using them. Chapter Topics: Strings are Immutable

More information

Topic 7 parameters. Based on slides from Marty Stepp and Stuart Reges from

Topic 7 parameters. Based on slides from Marty Stepp and Stuart Reges from Topic 7 parameters "We're flooding people with information. We need to feed it through a processor. A human must turn information into intelligence or knowledge. We've tended to forget that no computer

More information

CMSC201 Computer Science I for Majors

CMSC201 Computer Science I for Majors CMSC201 Computer Science I for Majors Lecture 05 Algorithmic Thinking Last Class We Covered Decision structures One-way (using if) Two-way (using if and else) Multi-way (using if, elif, and else) Nested

More information

A Unicorn Named Sparkle Word Search. A New Friend for Sparkle Coloring Sheet. A Unicorn Named Sparkle s First Christmas Coloring Sheet

A Unicorn Named Sparkle Word Search. A New Friend for Sparkle Coloring Sheet. A Unicorn Named Sparkle s First Christmas Coloring Sheet Table of Contents Page 1 Page 2 Page 3 Page 4 Page 5 Page 6 Page 7 Pages 8 9 Page 10 Page 11 Page 12 Page 13 Page 14 Page 15 Name Tags A Unicorn Named Sparkle Word Search Draw and Name Your Unicorn Connect

More information

School of Computer Science CPS109 Course Notes 6 Alexander Ferworn Updated Fall 15. CPS109 Course Notes 6. Alexander Ferworn

School of Computer Science CPS109 Course Notes 6 Alexander Ferworn Updated Fall 15. CPS109 Course Notes 6. Alexander Ferworn CPS109 Course Notes 6 Alexander Ferworn Unrelated Facts Worth Remembering Use metaphors to understand issues and explain them to others. Look up what metaphor means. Table of Contents Contents 1 ITERATION...

More information

UEE1302 (1102) F10: Introduction to Computers and Programming

UEE1302 (1102) F10: Introduction to Computers and Programming Computational Intelligence on Automation Lab @ NCTU Learning Objectives UEE1302 (1102) F10: Introduction to Computers and Programming Programming Lecture 00 Programming by Example Introduction to C++ Origins,

More information

The diagram below is only partially complete. Use the terms in the word list to complete the empty boxes. Make dinner

The diagram below is only partially complete. Use the terms in the word list to complete the empty boxes. Make dinner Decomposing Problems As we have seen, decomposition means breaking down a difficult problem into more manageable pieces. A common way to tackle this process is to use a tree diagram showing increasing

More information

C++ Support Classes (Data and Variables)

C++ Support Classes (Data and Variables) C++ Support Classes (Data and Variables) School of Mathematics 2018 Today s lecture Topics: Computers and Programs; Syntax and Structure of a Program; Data and Variables; Aims: Understand the idea of programming

More information

COMP-202 Unit 4: Programming With Iterations. CONTENTS: The while and for statements

COMP-202 Unit 4: Programming With Iterations. CONTENTS: The while and for statements COMP-202 Unit 4: Programming With Iterations CONTENTS: The while and for statements Introduction (1) Suppose we want to write a program to be used in cash registers in stores to compute the amount of money

More information

CSC 1051 Algorithms and Data Structures I. Midterm Examination February 24, Name: KEY 1

CSC 1051 Algorithms and Data Structures I. Midterm Examination February 24, Name: KEY 1 CSC 1051 Algorithms and Data Structures I Midterm Examination February 24, 2014 Name: KEY 1 Question Value Score 1 10 2 10 3 10 4 10 5 10 6 10 7 10 8 10 9 10 10 10 TOTAL 100 Please answer questions in

More information

CMSC 201 Fall 2016 Lab 09 Advanced Debugging

CMSC 201 Fall 2016 Lab 09 Advanced Debugging CMSC 201 Fall 2016 Lab 09 Advanced Debugging Assignment: Lab 09 Advanced Debugging Due Date: During discussion Value: 10 points Part 1: Introduction to Errors Throughout this semester, we have been working

More information

AP Computer Science A Summer Assignment 2017

AP Computer Science A Summer Assignment 2017 AP Computer Science A Summer Assignment 2017 The objective of this summer assignment is to ensure that each student has the ability to compile and run code on a computer system at home. We will be doing

More information