CSC 121 Spring 2017 Howard Rosenthal

Size: px
Start display at page:

Download "CSC 121 Spring 2017 Howard Rosenthal"

Transcription

1 CSC 121 Spring 2017 Howard Rosenthal

2 Agenda To be able to define computer program, algorithm, and highlevel programming language. To be able to list the basic stages involved in writing a computer program. To be able to apply an appropriate problem-solving method for developing an algorithmic solution to a problem. To understand the use of flowcharts and pseudocode These notes come from:

3 What Is Programming Some Programming - Planning or scheduling the performance of a task or an event Electronic computer - A programmable device that can store, retrieve, and process data Data - Information in a form a computer can use Information - Any knowledge that can be communicated Data type - The specification of how information is represented in the computer as data and the set of operations that can be applied to it We already have seen the primitive data types that Java supports Computer programming - The process of specifying the data types and the operations for a computer to apply to data in order to solve a problem Computer program - Data type specifications and instructions for carrying out operations that are used by a computer to solve a problem 3

4 What Can We Do With Programming Languages A computer can transfer data from one place to another. A computer can get data from an input device (a keyboard or mouse, for example) and write data to an output device (a screen, for example). A computer can store data into and retrieve data from its memory and secondary storage A computer can compare data values for equality or inequality and make decisions based on the result. A computer can perform arithmetic operations (addition and subtraction, for example) very quickly. A computer can branch to a different section of the instructions. Based on a conditional test (with an if like construct) you can execute or skip an instruction or set of instructions Based on a conditional test you have the ability to loop around and iterate through the same instructions many times, until the condition becomes false You also can jump to and from other programs (or subprograms, which are known as methods in Java) 4

5 The Programming Process (1) PROBLEM-SOLVING PHASE IMPLEMENTATION PHASE Analysis and specification General solution (algorithm) Concrete solution (program) Verify Test Maintenance phase Figure 1.1 Programming process 5

6 The Programming Process (2) Problem-Solving Phase Analysis and Specification. Understand (define) the problem and what the solution must do. General Solution (Algorithm). Specify the required data types and the logical sequences of steps that solve the problem. This is typically done with flow charts or pseudocode Verify. Follow the steps exactly to see if the solution really does solve the problem. This means taking some test cases and verifying that you are getting the expected answers Implementation Phase Concrete Solution (Program). Translate the algorithm (the general solution) into a programming language. Test. Have the computer follow the instructions. Then manually check the results. If you find errors, analyze the program and the algorithm to determine the source of the errors, and then make corrections. Once a program has been written, it enters a third phase: maintenance. Maintenance Phase Use. Use the program. Maintain. Modify the program to meet changing requirements or to correct any errors that show up while using it. The Most Important Part Is Finding A Solution To The Problem, Then The Implementation Is Easy 6

7 Algorithms An algorithm is a written or verbal description of a logical sequence of actions applied to objects. It is a procedure for solving a problem in a specific order that Describes the actions to be performed Describes the order in which these actions are performed We use algorithms every day. Recipes, instructions, and directions are all examples of algorithms that are not programs. An algorithm can be implemented in a programming language(s) as needed to rapidly and repetitively solve a problem A simple example of an algorithm that determines an employee s wages 1. Look up the employee s pay rate. 2. Determine the hours worked during the week. 3. If the number of hours worked is less than or equal to 40, multiply the hours by the pay rate to calculate regular wages. 4. If the number of hours worked is greater than 40, multiply 40 by the pay rate to calculate regular wages, and then multiply the difference between the hours worked and 40 by times the pay rate to calculate overtime wages. 5. Add the regular wages to the overtime wages (if any) to determine total wages for the week. 7

8 From Algorithm to (1) Don t code until your strategy and algorithms are worked out If you start by trying to code without a strategy for solving a problem you will run into trouble Coding is translating your solution from English to a computer language PROBLEM-SOLVING PHASE Problem Algorithm Shortcut? Code IMPLEMENTATION PHASE Figure 1.3 8

9 From Algorithm to (2) You then code your program using the correct syntax If there are errors the compiler will show them to you Once the program is syntactically correct it will execute You need to test the program to make sure that it is giving you the expected results Multiple test cases are used to ensure program correctness COMPILATION Source code Computer executes compiler code Code listing, possibly with error messages. Machine language version of source code (object code) Loading EXECUTION Input data Computer executes machine language version of source code Results Figure 1.7 Compilation/Execution 9

10 A Simple Set of Steps For Algorithmic Programming (1) 1. Read the problem completely twice If you don t understand the problem, you cannot solve it. The better you understand it the easier it with be to solve 2. Solve the problem manually Nothing can be automated that cannot be done manually (with enough effort) You need to be able to predict the outcome in some test cases in order to ensure that the program is working correctly Understand what you are doing when solving the problem. This will help you better understand the algorithms you are using 10

11 A Simple Set of Steps For Algorithmic Programming (2) 3. Optimize the manual solution It is much easier to rearrange and reconstruct an idea or algorithm in plain English than it is in code Sometimes optimization takes place through consolidation of loops, if statements, and other techniques you became familiar with in Create pseudocode or flow diagrams Pseud0-code uses English like phrases to describe the logical steps to carry out a task Pseudocode Java add grade to total total = total + grade; Print grade System.out.println( The grade is + grade); A flowcharts graphically depicts the logical steps to carry out a task and shows how the steps relate to one another You can lay out the program steps before worrying about the syntax Sometimes the pseudocode may be very close to the syntactically correct code When writing pseudocode write enough comments so that you can understand what you are doing 11

12 A Simple Set of Steps For Algorithmic Programming (3) 5. Replace pseudocode with real, syntactically correct code Compile and debug 6. Execute the code and test it Use multiple test cases to ensure it works properly Examples If searching a list make sure it can find a number at the beginning, somewhere in the middle, and at the end Make sure to test for cases where a value is 0 and for negative as well as positive numbers whenever appropriate 7. Review the code and optimize it, then repeat steps 5 and 6 Have confidence in the process and practice of creating your programs this ways 12

13 Applying The Process (1) Read and analyze the problem Reverse a string of characters (let s use the string Zebra ) When we are done we have created the new String arbez Solve the problem manually - Write Zebra down. - Start a new word, and put a as the first letter. (Why > because it is the last letter, we want to start here) - Put r down as the 2nd letter. (Why > because it is the next letter backwards from the last letter we copied) - Put b down as the 3rd letter. (Why > same as above) - Continue with subsequent letters until done 13

14 Applying The Process (2) Optimize the manual solution 1 Write Zebra down. 2 Start at the last letter in the word and create a new empty word. 3 Append the current letter to the new word 4 If there is a previous letter, make the previous letter the current letter and return to step 3. 14

15 Applying The Process (3) Write the pseudocode or comments - //Read in String to reverse - // NewWord = - // Loop backwards through word to reverse - // NewWord += CurrentLetter Replace comments with real code System.out.println( Enter a String to reverse ); String oldword = keyboard.next(); String newword = for(int index = oldword.length() 1; index >= 0; index--) newword = newword +oldword.charat(index); 15

16 Problem Solving Techniques (1) Ask Questions!!! What do I have to work with that is, what are my data/ inputs? What do the data items look like What is my output and what should it look like? You can work backwards from the output once you understand what it looks like What are the operations to be performed on the data to convert the inputs to outputs. How much data is there? How will I know when I have processed all the data What special error conditions might come up? The Important Thing Is To Analyze the Problem and Develop a Strategy Before You Begin Programming 16

17 Problem Solving Techniques (2) Look For Familiar Patterns Many problems are similar (even between the labs and the homework In the examples below we are simply looking for the highest and lowest values We can use the same algorithm in both cases Find analogies with other types of problems If you organize files in a cabinet that might give you some ideas on how to organize computer files LIST OF TEMPERATURES Use the same method to find these values in both cases. LIST OF TEST SCORES HIGHEST = 95 LOWEST = 18 HIGHEST = 98 LOWEST = 12 17

18 Problem Solving Techniques (3) Means-Ends Analysis Figure out what the end-state is and then determine how to get there from the initial state There are often alternative ways to get to your end state As you go along there may be intermediate end states that are easier to reach Start: Boston Goal: Austin Start: Boston Goal: Austin Start: Boston Intermediate Goal: Newark Goal: Austin Means: Fly, walk, hitchhike, bike, drive, sail, bus Revised Means: Fly to Chicago and then Austin; fly to Newark and then Austin: fly to Atlanta and then Austin Means to Intermediate Goal: Commuter flight, walk, hitchhike, bike, drive, sail, bus Solution: Take commuter flight to Newark and then catch cheap flight to Austin Figure 1.15 Means-ends analysis 18

19 Problem Solving Techniques (4) Divide and Conquer The most popular technique Break up your hard problem into smaller, more easily solvable problems Develop a strategy for solving the easier problems (which can themselves be divided into smaller problems) Hard problem Easy subproblem Hard subproblem Easy subproblem Easy subsubproblem Easy subsubproblem Figure 1.16 Divide and conquer 19

20 Problem Solving Techniques (5) Building Blocks and Merging Solutions Take pieces from existing programs and use them in a larger solution We do this almost from the beginning in Java, using IO solutions that are provided as part of Java in order to read in data and write out results. Java has a huge number of libraries with programs that can be used to simplify our programming In the beginning we often recreate some of these tools to better understand computing principles 20

21 The Flowchart A Flowchart Shows logic of an algorithm Emphasizes individual steps and their interconnections Shows control flow from one action to the next 21

22 Flowchart Symbols Name Symbol Use in Flowchart Oval Denotes the beginning or end of the program Parallelogram Denotes an input operation Rectangle Denotes a process to be carried out e.g. addition, subtraction, division etc. Diamond Denotes a decision (or branch) to be made. The program should continue along one of two routes. (e.g. IF/THEN/ELSE) Hybrid Denotes an output operation Flow line Denotes the direction of logic flow in the program 22

23 Example 1 Write an algorithm and draw a flowchart to convert the length in feet to centimeters. Pseudocode: Input the length in feet (lengthinfeet) Calculate the length in cm (lengthincentimeters) by multiplying lengthinfeet with 30.0 Print length in cm (lengthincentimeters) 23

24 Example 1 Algorithm Step 1: Input lengthinfeet Step 2: lengthincentimeters lengthinfeet * 30 Step 3: Print lengthincentimeters Flowchart START Input lengthinfeet lengthincentimeters lengthinfeet * 30.0 Print lengthincentimeters STOP 24

25 Example 2 Write an algorithm and draw a flowchart that will calculate the roots of a quadratic equation 2 ax + bx + c = 0 Hint: d = sqrt ( b 2 4*a *c ), and the roots are: x1 = ( b + d)/2*a and x2 = ( b d)/2*a 25

26 Example 2 Pseudocode: Input the coefficients (a, b, c) of the quadratic equation Calculate d Calculate x1 Calculate x2 Print x1 and x2 26

27 Example 2 Algorithm and Flowchart Algorithm: Step 1: Input a, b, c Step 2: d sqrt ( ) Step 3: b*b 4*a *c x1 ( b + d) / (2 *a) Step 4: x2 ( b d) / (2 * a) Step 5: Print x1, x2 START Input a, b, c d sqrt(b * b 4*a * c) x 1 ( b + d) / (2 * a) X 2 ( b d) / (2 * a) Print x 1,x 2 STOP 27

28 IF THEN ELSE STRUCTURE The structure is as follows If condition then true alternative else false alternative endif 28

29 IF THEN ELSE STRUCTURE The algorithm for the flowchart is as follows: If A>B then print A else print B endif Y Print A is A>B N Print B 29

30 Looping Flowchart 30

31 Example 3 Write an algorithm to determine a student s final grade and indicate whether it is passing or failing. The final grade is calculated as the average of four marks. 31

32 Example 3 Pseudocode & Algorithm (1) Pseudocode: Input a set of 4 marks Calculate their average by summing the grades and then dividing by 4.0 if average is below 50 Print FAIL else Print PASS 32

33 Example 3 Pseudocode & Algorithm (2) Detailed Algorithm Step 1: Input M1,M2,M3,M4 Step 2: GRADE (M1+M2+M3+M4)/4.0 Step 3: if (GRADE < 50) then Print FAIL else Print PASS endif 33

34 Example 3 Flowchart START Input M1,M2,M3,M4 GRADE (M1+M2+M3+M4)/4.0 Step 1: Step 2: Step 3: Input M1,M2,M3,M4 GRADE (M1+M2+M3+M4)/4 if (GRADE <50) then Print FAIL else Print PASS endif N IS GRADE<50 Y PRINT PASS PRINT FAIL STOP 34

35 In Class Problem 1 Direction of Numbered NYC Streets Algorithm Problem: Given a street number of a one-way street in New York City, decide the direction of the street, either eastbound or westbound Discussion: in New York City even numbered streets are Eastbound, odd numbered streets are Westbound Write the Pseudocode and Flowchart for this Problem Do you know how you can determine if an integer is even or odd? 35

36 Class Problem 1 Pseudocode Program: Determine the direction of a numbered NYC street Get street If street number is even Then Display Eastbound Else Display Westbound End If 36

37 Class Problem 1 Flowchart 37

38 Class Problem 2 Class Average Algorithm Problem: Calculate and report the grade-point average for a class Discussion: The average grade equals the sum of all grades divided by the number of students Output: Average grade Input: Student grades Processing: Find the sum of the grades; count the number of students; calculate average Write the Pseudocode and Flowchart for this Problem 38

39 Class Problem 2 Pseudocode Program: Determine the average grade of a class Initialize Counter and Sum to 0 Do While there are more data Get the next Grade Add the Grade to the Sum Increment the Counter Loop Average = Sum / (double)counter Display Average 39

40 Class Problem 2 Flowchart 40

ALGORITHMS AND FLOWCHARTS

ALGORITHMS AND FLOWCHARTS ALGORITHMS AND FLOWCHARTS ALGORITHMS AND FLOWCHARTS A typical programming task can be divided into two phases: Problem solving phase produce an ordered sequence of steps that describe solution of problem

More information

PSEUDOCODE AND FLOWCHARTS. Introduction to Programming

PSEUDOCODE AND FLOWCHARTS. Introduction to Programming PSEUDOCODE AND FLOWCHARTS Introduction to Programming What s Pseudocode? Artificial and Informal language Helps programmers to plan an algorithm Similar to everyday English Not an actual programming language

More information

UNDERSTANDING PROBLEMS AND HOW TO SOLVE THEM BY USING COMPUTERS

UNDERSTANDING PROBLEMS AND HOW TO SOLVE THEM BY USING COMPUTERS UNDERSTANDING PROBLEMS AND HOW TO SOLVE THEM BY USING COMPUTERS INTRODUCTION TO PROBLEM SOLVING Introduction to Problem Solving Understanding problems Data processing Writing an algorithm CONTINUE.. Tool

More information

CS111: PROGRAMMING LANGUAGE1. Lecture 2: Algorithmic Problem Solving

CS111: PROGRAMMING LANGUAGE1. Lecture 2: Algorithmic Problem Solving CS111: PROGRAMMING LANGUAGE1 Lecture 2: Algorithmic Problem Solving Agenda 2 Problem Solving Techniques Pseudocode Algorithm Flow charts Examples How People Solve Problems 3 A Problem exists when what

More information

CS 199 Computer Programming. Spring 2018 Lecture 2 Problem Solving

CS 199 Computer Programming. Spring 2018 Lecture 2 Problem Solving CS 199 Computer Programming Spring 2018 Lecture 2 Problem Solving ALGORITHMS AND FLOWCHARTS A typical programming task can be divided into two phases: Problem solving phase produce an ordered sequence

More information

Computer System and programming in C

Computer System and programming in C Approaches to Problem Solving Concept of algorithm and flow charts ALGORITHMS AND FLOWCHARTS A typical programming task can be divided into two phases: Problem solving phase produce an ordered sequence

More information

Python - Week 1. Mohammad Shokoohi-Yekta

Python - Week 1. Mohammad Shokoohi-Yekta Python - Week 1 Mohammad Shokoohi-Yekta 1 An Introduction to Computers and Problem Solving 1.1 An Introduction to Computers 1.2 Program Development Cycle 1.3 Programming Tools 1.4 Starting Python 2 Communicating

More information

Class 8 ALGORITHMS AND FLOWCHARTS. The City School

Class 8 ALGORITHMS AND FLOWCHARTS. The City School Class 8 ALGORITHMS AND FLOWCHARTS ALGORITHMS AND FLOWCHARTS A typical programming task can be divided into two phases: Problem solving phase produce an ordered sequence of steps that describe solution

More information

Chapter 1 - An Introduction to Computers and Problem Solving

Chapter 1 - An Introduction to Computers and Problem Solving Chapter 1 - An Introduction to Computers and Problem Solving 1.1 An Introduction to Computers 1.2 Windows, Folders, and Files 1.3 Program Development Cycle 1.4 Programming Tools 1 1.1 An Introduction to

More information

Chapter 2 - Problem Solving

Chapter 2 - Problem Solving Chapter 2 - Problem Solving Program Development Cycle Programming Tools Chapter 2 - VB.NET by Schneider 1 Terminology tip A computer program may also be called: Project (Visual Studio 6 term) Application

More information

Method & Tools for Program Analysis & Design

Method & Tools for Program Analysis & Design Method & Tools for Program Analysis & Design TMB208 Pemrograman Teknik Kredit: 3 (2-3) 1 Programming Logic and Design, Introductory, Fourth Edition 2 1 Programming Methods Based on structures of programming

More information

FLOW CHART AND PSEUDO CODE

FLOW CHART AND PSEUDO CODE FLOW CHART AND PSEUDO CODE Flowchart A Flowchart is a pictorial representation of an algorithm. The First flowchart is made by John Von Newman in 1945. It is a symbolic diagram of operation sequence, dataflow,

More information

Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Spring 2016 Howard Rosenthal

Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Spring 2016 Howard Rosenthal Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Spring 2016 Howard Rosenthal Lesson Goals Understand Control Structures Understand how to control the flow of a program

More information

Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Fall 2016 Howard Rosenthal

Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Fall 2016 Howard Rosenthal Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Fall 2016 Howard Rosenthal Lesson Goals Understand Control Structures Understand how to control the flow of a program

More information

MAT 003 Brian Killough s Instructor Notes Saint Leo University

MAT 003 Brian Killough s Instructor Notes Saint Leo University MAT 003 Brian Killough s Instructor Notes Saint Leo University Success in online courses requires self-motivation and discipline. It is anticipated that students will read the textbook and complete sample

More information

IDENTIFY WAYS OF REPRESENTING ALGORITHMS.

IDENTIFY WAYS OF REPRESENTING ALGORITHMS. IDENTIFY WAYS OF REPRESENTING ALGORITHMS. OBJECTIVES: Identify ways of representing algorithms: Content Representation of algorithms as Pseudocode or Flowcharts; use of flow chart symbols: input/output

More information

Java and Software Design

Java and Software Design Introduction to Java and Software Design Jindal Consulting Chapter 1 Overview of Programming and Problem Solving Slides by Varun Jindal 1 Chapter 1 Topics Computer Programming Programming Life-Cycle Phases

More information

Module 1: Introduction to Computers, Programs, and Java

Module 1: Introduction to Computers, Programs, and Java Module 1: Introduction to Computers, Programs, and Java Module 1: Introduction to Java page 1 Objectives To review Program Design and Problem-Solving Techniques To describe the relationship between Java

More information

Condition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution.

Condition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution. Repetition Structures Introduction to Repetition Structures Chapter 5 Spring 2016, CSUS Chapter 5.1 Introduction to Repetition Structures The Problems with Duplicate Code A repetition structure causes

More information

The Further Mathematics Support Programme

The Further Mathematics Support Programme The Further Mathematics Support Programme Algorithms An algorithm is a precise set of instructions which is used to accomplish a specific process. We come across algorithms in every-day life, for example:

More information

PROGRAM DESIGN TOOLS. Algorithms, Flow Charts, Pseudo codes and Decision Tables. Designed by Parul Khurana, LIECA.

PROGRAM DESIGN TOOLS. Algorithms, Flow Charts, Pseudo codes and Decision Tables. Designed by Parul Khurana, LIECA. PROGRAM DESIGN TOOLS Algorithms, Flow Charts, Pseudo codes and Decision Tables Introduction The various tools collectively referred to as program design tools, that helps in planning the program are:-

More information

Repetition Structures

Repetition Structures Repetition Structures Chapter 5 Fall 2016, CSUS Introduction to Repetition Structures Chapter 5.1 1 Introduction to Repetition Structures A repetition structure causes a statement or set of statements

More information

Chapter 1: Problem Solving Skills Introduction to Programming GENG 200

Chapter 1: Problem Solving Skills Introduction to Programming GENG 200 Chapter 1: Problem Solving Skills Introduction to Programming GENG 200 Spring 2014, Prepared by Ali Abu Odeh 1 Table of Contents Fundamentals of Flowcharts 2 3 Flowchart with Conditions Flowchart with

More information

Lecture Notes for Chapter 2: Getting Started

Lecture Notes for Chapter 2: Getting Started Instant download and all chapters Instructor's Manual Introduction To Algorithms 2nd Edition Thomas H. Cormen, Clara Lee, Erica Lin https://testbankdata.com/download/instructors-manual-introduction-algorithms-2ndedition-thomas-h-cormen-clara-lee-erica-lin/

More information

Loops (while and for)

Loops (while and for) Loops (while and for) CSE 1310 Introduction to Computers and Programming Alexandra Stefan 1 Motivation Was there any program we did (class or hw) where you wanted to repeat an action? 2 Motivation Name

More information

Course Outline. Introduction to java

Course Outline. Introduction to java Course Outline 1. Introduction to OO programming 2. Language Basics Syntax and Semantics 3. Algorithms, stepwise refinements. 4. Quiz/Assignment ( 5. Repetitions (for loops) 6. Writing simple classes 7.

More information

Repe$$on CSC 121 Spring 2017 Howard Rosenthal

Repe$$on CSC 121 Spring 2017 Howard Rosenthal Repe$$on CSC 121 Spring 2017 Howard Rosenthal Lesson Goals Learn the following three repetition structures in Java, their syntax, their similarities and differences, and how to avoid common errors when

More information

Chapter Two: Program Design Process and Logic

Chapter Two: Program Design Process and Logic Chapter Two: Program Design Process and Logic 2.1 Chapter objectives Describe the steps involved in the programming process Understand how to use flowchart symbols and pseudocode statements Use a sentinel,

More information

Visual Basic -Chapter 1

Visual Basic -Chapter 1 Visual Basic -Chapter 1 Mohammad Shokoohi * Adopted from An Introduction to Programming Using Visual Basic 2010, Schneider 1 Chapter 1 -An Introduction to Computers and Problem Solving 1.1 An Introduction

More information

BRANCHING if-else statements

BRANCHING if-else statements BRANCHING if-else statements Conditional Statements A conditional statement lets us choose which statement t t will be executed next Therefore they are sometimes called selection statements Conditional

More information

Lecture 2: Getting Started

Lecture 2: Getting Started Lecture 2: Getting Started Insertion Sort Our first algorithm is Insertion Sort Solves the sorting problem Input: A sequence of n numbers a 1, a 2,..., a n. Output: A permutation (reordering) a 1, a 2,...,

More information

Outline. Program development cycle. Algorithms development and representation. Examples.

Outline. Program development cycle. Algorithms development and representation. Examples. Outline Program development cycle. Algorithms development and representation. Examples. 1 Program Development Cycle Program development cycle steps: Problem definition. Problem analysis (understanding).

More information

STUDENT LESSON A12 Iterations

STUDENT LESSON A12 Iterations STUDENT LESSON A12 Iterations Java Curriculum for AP Computer Science, Student Lesson A12 1 STUDENT LESSON A12 Iterations INTRODUCTION: Solving problems on a computer very often requires a repetition of

More information

Algebra 2 Semester 1 (#2221)

Algebra 2 Semester 1 (#2221) Instructional Materials for WCSD Math Common Finals The Instructional Materials are for student and teacher use and are aligned to the 2016-2017 Course Guides for the following course: Algebra 2 Semester

More information

REPETITION CONTROL STRUCTURE LOGO

REPETITION CONTROL STRUCTURE LOGO CSC 128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING REPETITION CONTROL STRUCTURE 1 Contents 1 Introduction 2 for loop 3 while loop 4 do while loop 2 Introduction It is used when a statement or a block of

More information

Advanced Algebra I Simplifying Expressions

Advanced Algebra I Simplifying Expressions Page - 1 - Name: Advanced Algebra I Simplifying Expressions Objectives The students will be able to solve problems using order of operations. The students will identify expressions and write variable expressions.

More information

Chapter 3. More Flow of Control. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Chapter 3. More Flow of Control. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 More Flow of Control Overview 3.1 Using Boolean Expressions 3.2 Multiway Branches 3.3 More about C++ Loop Statements 3.4 Designing Loops Slide 3-3 Flow Of Control Flow of control refers to the

More information

SNS COLLEGE OF ENGINEERING,

SNS COLLEGE OF ENGINEERING, SNS COLLEGE OF ENGINEERING, COIMBATORE Department of Computer Science and Engineering QUESTION BANK(PART A) GE8151 - PROBLEM SOLVING AND PYTHON PROGRAMMING TWO MARKS UNIT-I 1. What is computer? Computers

More information

Conditional Execution

Conditional Execution Unit 3, Part 3 Conditional Execution Computer Science S-111 Harvard University David G. Sullivan, Ph.D. Review: Simple Conditional Execution in Java if () { else {

More information

Unit 1 Lesson 4. Introduction to Control Statements

Unit 1 Lesson 4. Introduction to Control Statements Unit 1 Lesson 4 Introduction to Control Statements Essential Question: How are control loops used to alter the execution flow of a program? Lesson 4: Introduction to Control Statements Objectives: Use

More information

Algorithms: The recipe for computation

Algorithms: The recipe for computation Algorithms: The recipe for computation 2C Visualizing Algorithms with Flowcharts 15-105 Principles of Computation, Carnegie Mellon University - CORTINA 1 Flowcharts Flowcharts are used to show the flow

More information

The sequence of steps to be performed in order to solve a problem by the computer is known as an algorithm.

The sequence of steps to be performed in order to solve a problem by the computer is known as an algorithm. CHAPTER 1&2 OBJECTIVES After completing this chapter, you will be able to: Understand the basics and Advantages of an algorithm. Analysis various algorithms. Understand a flowchart. Steps involved in designing

More information

C++ Programming Language Lecture 2 Problem Analysis and Solution Representation

C++ Programming Language Lecture 2 Problem Analysis and Solution Representation C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department Program Development Cycle Program development

More information

Big Mathematical Ideas and Understandings

Big Mathematical Ideas and Understandings Big Mathematical Ideas and Understandings A Big Idea is a statement of an idea that is central to the learning of mathematics, one that links numerous mathematical understandings into a coherent whole.

More information

Introduction to Software Development (ISD) David Weston and Igor Razgon

Introduction to Software Development (ISD) David Weston and Igor Razgon Introduction to Software Development (ISD) David Weston and Igor Razgon Autumn term 2013 Course book The primary book supporting the ISD module is: Java for Everyone, by Cay Horstmann, 2nd Edition, Wiley,

More information

Control Structures in Java if-else and switch

Control Structures in Java if-else and switch Control Structures in Java if-else and switch Lecture 4 CGS 3416 Spring 2017 January 23, 2017 Lecture 4CGS 3416 Spring 2017 Selection January 23, 2017 1 / 26 Control Flow Control flow refers to the specification

More information

The births of the generations are as follow. First generation, 1945 machine language Second generation, mid 1950s assembly language.

The births of the generations are as follow. First generation, 1945 machine language Second generation, mid 1950s assembly language. Lesson Outcomes At the end of this chapter, student should be able to: Describe what a computer program is Explain the importance of programming to computer use Appreciate the importance of good programs

More information

1 Information system An information system is the combination of technology(computers) and people that enable an organization to collect data, store them, and transform them into information Data Data

More information

PROGRAM DESIGN TOOLS. Algorithms, Flow Charts, Pseudo codes and Decision Tables. Designed by Parul Khurana, LIECA.

PROGRAM DESIGN TOOLS. Algorithms, Flow Charts, Pseudo codes and Decision Tables. Designed by Parul Khurana, LIECA. PROGRAM DESIGN TOOLS Algorithms, Flow Charts, Pseudo codes and Decision Tables Pseudo-Code Pseudo-code is another programming tool that is used for planning the program. The word pseudo means imitation

More information

WHOLE NUMBER AND DECIMAL OPERATIONS

WHOLE NUMBER AND DECIMAL OPERATIONS WHOLE NUMBER AND DECIMAL OPERATIONS Whole Number Place Value : 5,854,902 = Ten thousands thousands millions Hundred thousands Ten thousands Adding & Subtracting Decimals : Line up the decimals vertically.

More information

Statistics Case Study 2000 M. J. Clancy and M. C. Linn

Statistics Case Study 2000 M. J. Clancy and M. C. Linn Statistics Case Study 2000 M. J. Clancy and M. C. Linn Problem Write and test functions to compute the following statistics for a nonempty list of numeric values: The mean, or average value, is computed

More information

Concept of algorithms Understand and use three tools to represent algorithms: Flowchart Pseudocode Programs

Concept of algorithms Understand and use three tools to represent algorithms: Flowchart Pseudocode Programs Morteza Noferesti Concept of algorithms Understand and use three tools to represent algorithms: Flowchart Pseudocode Programs We want to solve a real problem by computers Take average, Sort, Painting,

More information

ALGEBRA 1 NOTES. Quarter 3. Name: Block

ALGEBRA 1 NOTES. Quarter 3. Name: Block 2016-2017 ALGEBRA 1 NOTES Quarter 3 Name: Block Table of Contents Unit 8 Exponent Rules Exponent Rules for Multiplication page 4 Negative and Zero Exponents page 8 Exponent Rules Involving Quotients page

More information

Chapter 0: Algebra II Review

Chapter 0: Algebra II Review Chapter 0: Algebra II Review Topic 1: Simplifying Polynomials & Exponential Expressions p. 2 - Homework: Worksheet Topic 2: Radical Expressions p. 32 - Homework: p. 45 #33-74 Even Topic 3: Factoring All

More information

UNIT 5 QUADRATIC FUNCTIONS Lesson 1: Interpreting Structure in Expressions Instruction

UNIT 5 QUADRATIC FUNCTIONS Lesson 1: Interpreting Structure in Expressions Instruction Prerequisite Skills This lesson requires the use of the following skills: translating verbal expressions to algebraic expressions evaluating expressions following the order of operations adding and subtracting

More information

Lab 2: Structured Program Development in C

Lab 2: Structured Program Development in C Lab 2: Structured Program Development in C (Part A: Your first C programs - integers, arithmetic, decision making, Part B: basic problem-solving techniques, formulating algorithms) Learning Objectives

More information

Condition Controlled Loops. Introduction to Programming - Python

Condition Controlled Loops. Introduction to Programming - Python + Condition Controlled Loops Introduction to Programming - Python + Repetition Structures n Programmers commonly find that they need to write code that performs the same task over and over again + Example:

More information

Common Core State Standards Mathematics (Subset K-5 Counting and Cardinality, Operations and Algebraic Thinking, Number and Operations in Base 10)

Common Core State Standards Mathematics (Subset K-5 Counting and Cardinality, Operations and Algebraic Thinking, Number and Operations in Base 10) Kindergarten 1 Common Core State Standards Mathematics (Subset K-5 Counting and Cardinality,, Number and Operations in Base 10) Kindergarten Counting and Cardinality Know number names and the count sequence.

More information

Sand Springs Public Schools 3rd Grade Math Common Core State Standards

Sand Springs Public Schools 3rd Grade Math Common Core State Standards 1 st Six Weeks Patterns and Relationships Algebraic Reasoning: Patters and Re la tio n s h ip s The student will use a variety of problem-solving approaches to extend and create patterns. A 1.1 Describe

More information

Control Structures. Code can be purely arithmetic assignments. At some point we will need some kind of control or decision making process to occur

Control Structures. Code can be purely arithmetic assignments. At some point we will need some kind of control or decision making process to occur Control Structures Code can be purely arithmetic assignments At some point we will need some kind of control or decision making process to occur C uses the if keyword as part of it s control structure

More information

For more information, see the Math Notes box in Lesson of the Core Connections, Course 1 text.

For more information, see the Math Notes box in Lesson of the Core Connections, Course 1 text. Number TYPES OF NUMBERS When two or more integers are multiplied together, each number is a factor of the product. Nonnegative integers that have eactly two factors, namely, one and itself, are called

More information

IT 1033: Fundamentals of Programming Loops

IT 1033: Fundamentals of Programming Loops IT 1033: Fundamentals of Programming Loops Budditha Hettige Department of Computer Science Repetitions: Loops A loop is a sequence of instruction s that is continually repeated until a certain condition

More information

Modesto City Schools. Secondary Math I. Module 1 Extra Help & Examples. Compiled by: Rubalcava, Christina

Modesto City Schools. Secondary Math I. Module 1 Extra Help & Examples. Compiled by: Rubalcava, Christina Modesto City Schools Secondary Math I Module 1 Extra Help & Examples Compiled by: Rubalcava, Christina 1.1 Ready, Set, Go! Ready Topic: Recognizing a solution to an equation. The solution to an equation

More information

Repe$$on CSC 121 Fall 2015 Howard Rosenthal

Repe$$on CSC 121 Fall 2015 Howard Rosenthal Repe$$on CSC 121 Fall 2015 Howard Rosenthal Lesson Goals Learn the following three repetition methods, their similarities and differences, and how to avoid common errors when using them: while do-while

More information

SOFTWARE ANALYSIS & DESIGN TOOLS

SOFTWARE ANALYSIS & DESIGN TOOLS SOFTWARE ANALYSIS & DESIGN TOOLS http://www.tutorialspoint.com/software_engineering/software_analysis_design_tools.htm Copyright tutorialspoint.com Software analysis and design includes all activities,

More information

Mini-Lectures by Section

Mini-Lectures by Section Mini-Lectures by Section BEGINNING AND INTERMEDIATE ALGEBRA, Mini-Lecture 1.1 1. Learn the definition of factor.. Write fractions in lowest terms.. Multiply and divide fractions.. Add and subtract fractions..

More information

Command-line interface DOS Graphical User interface (GUI) -- Windows

Command-line interface DOS Graphical User interface (GUI) -- Windows Introduction To Computer Programming g Outline Operating System Computer Programming Programming Life-Cycle Phases Creating an Algorithm Machine Language vs. High Level Languages Compilation and Execution

More information

CS112 Lecture: Repetition Statements

CS112 Lecture: Repetition Statements CS112 Lecture: Repetition Statements Objectives: Last revised 2/18/05 1. To explain the general form of the java while loop 2. To introduce and motivate the java do.. while loop 3. To explain the general

More information

Unit-II Programming and Problem Solving (BE1/4 CSE-2)

Unit-II Programming and Problem Solving (BE1/4 CSE-2) Unit-II Programming and Problem Solving (BE1/4 CSE-2) Problem Solving: Algorithm: It is a part of the plan for the computer program. An algorithm is an effective procedure for solving a problem in a finite

More information

SNS COLLEGE OF ENGINEERING

SNS COLLEGE OF ENGINEERING SNS COLLEGE OF ENGINEERING DEPARTMENT OF CSE Presented By Thillaiarasu.N SCRAMBLE 2 Solution 3 What is Pseudocode? 4 Consists of: Short Readable Formally styled English language Used for: Explaining the

More information

Pseudo Code and Flow Charts. Chapter 1 Lesson 2

Pseudo Code and Flow Charts. Chapter 1 Lesson 2 Pseudo Code and Flow Charts Chapter 1 Lesson 2 Pseudocode Using Pseudocode Statements and Flowchart Symbols English-like representation of the logical steps it takes to solve a problem Flowchart Pictorial

More information

Numerical Methods in Scientific Computation

Numerical Methods in Scientific Computation Numerical Methods in Scientific Computation Programming and Software Introduction to error analysis 1 Packages vs. Programming Packages MATLAB Excel Mathematica Maple Packages do the work for you Most

More information

EXCEL BASICS: MICROSOFT OFFICE 2010

EXCEL BASICS: MICROSOFT OFFICE 2010 EXCEL BASICS: MICROSOFT OFFICE 2010 GETTING STARTED PAGE 02 Prerequisites What You Will Learn USING MICROSOFT EXCEL PAGE 03 Opening Microsoft Excel Microsoft Excel Features Keyboard Review Pointer Shapes

More information

Object Oriented Programming Using C++ Mathematics & Computing IET, Katunayake

Object Oriented Programming Using C++ Mathematics & Computing IET, Katunayake Assigning Values // Example 2.3(Mathematical operations in C++) float a; cout > a; cout

More information

3 The L oop Control Structure

3 The L oop Control Structure 3 The L oop Control Structure Loops The while Loop Tips and Traps More Operators The for Loop Nesting of Loops Multiple Initialisations in the for Loop The Odd Loop The break Statement The continue Statement

More information

Solving Problems Flow Control in C++ CS 16: Solving Problems with Computers I Lecture #3

Solving Problems Flow Control in C++ CS 16: Solving Problems with Computers I Lecture #3 Solving Problems Flow Control in C++ CS 16: Solving Problems with Computers I Lecture #3 Ziad Matni Dept. of Computer Science, UCSB A Word About Registration for CS16 FOR THOSE OF YOU NOT YET REGISTERED:

More information

Flowchart Structure 25th October 2018

Flowchart Structure 25th October 2018 Flowchart Structure 25 th October 2018 Section 1: Basic rules in flowchart Section 2: Translating Pseudocode to Flowchart Algorithm Section3: Examples of Flowchart Section 4: Control structures (Sequence,

More information

Organisation. Assessment

Organisation. Assessment Week 1 s s Getting Started 1 3 4 5 - - Lecturer Dr Lectures Tuesday 1-13 Fulton House Lecture room Tuesday 15-16 Fulton House Lecture room Thursday 11-1 Fulton House Lecture room Friday 10-11 Glyndwr C

More information

Physics 326G Winter Class 6

Physics 326G Winter Class 6 Physics 36G Winter 008 Class 6 Today we will learn about functions, and also about some basic programming that allows you to control the execution of commands in the programs you write. You have already

More information

A Quick Review of Chapter 1

A Quick Review of Chapter 1 A Quick Review of Chapter 1 The core of computing is algorithms Algorithm A well-ordered collection of unambiguous and effectively computable operations that, when executed, produces a result and halts

More information

Repetition Algorithms

Repetition Algorithms Repetition Algorithms Repetition Allows a program to execute a set of instructions over and over. The term loop is a synonym for a repetition statement. A Repetition Example Suppose that you have been

More information

Raising achievement Foundation/Higher Tier Grades 1 9

Raising achievement Foundation/Higher Tier Grades 1 9 Year 8 Maths Revision List Summer 018 The list below should give an indication of the material that Year 8 pupils will be tested on in Summer 018. Pupils should rate their confidence in each of the skills

More information

Maths Revision Worksheet: Algebra I Week 1 Revision 5 Problems per night

Maths Revision Worksheet: Algebra I Week 1 Revision 5 Problems per night 2 nd Year Maths Revision Worksheet: Algebra I Maths Revision Worksheet: Algebra I Week 1 Revision 5 Problems per night 1. I know how to add and subtract positive and negative numbers. 2. I know how to

More information

Lecture 9. Monday, January 31 CS 205 Programming for the Sciences - Lecture 9 1

Lecture 9. Monday, January 31 CS 205 Programming for the Sciences - Lecture 9 1 Lecture 9 Reminder: Programming Assignment 3 is due Wednesday by 4:30pm. Exam 1 is on Friday. Exactly like Prog. Assign. 2; no collaboration or help from the instructor. Log into Windows/ACENET. Start

More information

Data can be in the form of numbers, words, measurements, observations or even just descriptions of things.

Data can be in the form of numbers, words, measurements, observations or even just descriptions of things. + What is Data? Data is a collection of facts. Data can be in the form of numbers, words, measurements, observations or even just descriptions of things. In most cases, data needs to be interpreted and

More information

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types

More information

CpSc 111 Lab 5 Conditional Statements, Loops, the Math Library, and Redirecting Input

CpSc 111 Lab 5 Conditional Statements, Loops, the Math Library, and Redirecting Input CpSc Lab 5 Conditional Statements, Loops, the Math Library, and Redirecting Input Overview For this lab, you will use: one or more of the conditional statements explained below scanf() or fscanf() to read

More information

CHAPTER 2 PROBLEM SOLVING TECHNIQUES. Mr Mohd Hatta Bin Hj Mohamed Ali Computer Programming BFC2042

CHAPTER 2 PROBLEM SOLVING TECHNIQUES. Mr Mohd Hatta Bin Hj Mohamed Ali Computer Programming BFC2042 CHAPTER 2 PROBLEM SOLVING TECHNIQUES Mr Mohd Hatta Bin Hj Mohamed Ali Computer Programming BFC2042 Software Engineering vs Problem Solving Software Engineering - A branch of Computer Science & provides

More information

5. Control Statements

5. Control Statements 5. Control Statements This section of the course will introduce you to the major control statements in C++. These control statements are used to specify the branching in an algorithm/recipe. Control statements

More information

Boolean Logic & Branching Lab Conditional Tests

Boolean Logic & Branching Lab Conditional Tests I. Boolean (Logical) Operations Boolean Logic & Branching Lab Conditional Tests 1. Review of Binary logic Three basic logical operations are commonly used in binary logic: and, or, and not. Table 1 lists

More information

Simplifying Expressions

Simplifying Expressions Unit 1 Beaumont Middle School 8th Grade, 2017-2018 Math8; Intro to Algebra Name: Simplifying Expressions I can identify expressions and write variable expressions. I can solve problems using order of operations.

More information

Common Core State Standards - Standards for Mathematical Practice

Common Core State Standards - Standards for Mathematical Practice Common Core State Standards - Standards for Mathematical Practice The Standards for Mathematical Practice describe varieties of expertise that mathematics educators at all levels should seek to develop

More information

CS111: PROGRAMMING LANGUAGE II

CS111: PROGRAMMING LANGUAGE II 1 CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1: Introduction Lecture Contents 2 Course info Why programming?? Why Java?? Write once, run anywhere!! Java basics Input/output Variables

More information

CMSC 201 Spring 2017 Lab 05 Lists

CMSC 201 Spring 2017 Lab 05 Lists CMSC 201 Spring 2017 Lab 05 Lists Assignment: Lab 05 Lists Due Date: During discussion, February 27th through March 2nd Value: 10 points (8 points during lab, 2 points for Pre Lab quiz) This week s lab

More information

Problem Solving and Program Design - Chapter 1. Cory L. Strope

Problem Solving and Program Design - Chapter 1. Cory L. Strope Problem Solving and Program Design - Chapter 1 Cory L. Strope Overview of Computers and Programming Computer Hardware Computer Software Software Development (Problem Solving) Pseudocode Flowchart Intro.

More information

INTENDED LEARNING OUTCOMES

INTENDED LEARNING OUTCOMES COURSE CODE: GEE 216 COURSE TITLE: COMPUTER AND COMPUTING NUMBER OF UNITS: 3 Units COURSE DURATION: Three hours per week COURSE LECTURER: Engr. Obasi Chukwuemeka INTENDED LEARNING OUTCOMES At the completion

More information

STUDENT OUTLINE. Lesson 8: Structured Programming, Control Structures, if-else Statements, Pseudocode

STUDENT OUTLINE. Lesson 8: Structured Programming, Control Structures, if-else Statements, Pseudocode STUDENT OUTLINE Lesson 8: Structured Programming, Control Structures, if- Statements, Pseudocode INTRODUCTION: This lesson is the first of four covering the standard control structures of a high-level

More information

Loops / Repetition Statements

Loops / Repetition Statements Loops / Repetition Statements Repetition statements allow us to execute a statement multiple times Often they are referred to as loops C has three kinds of repetition statements: the while loop the for

More information

To become familiar with array manipulation, searching, and sorting.

To become familiar with array manipulation, searching, and sorting. ELECTRICAL AND COMPUTER ENGINEERING 06-88-211: COMPUTER AIDED ANALYSIS LABORATORY EXPERIMENT #2: INTRODUCTION TO ARRAYS SID: OBJECTIVE: SECTIONS: Total Mark (out of 20): To become familiar with array manipulation,

More information

MATHEMATICS UTAH CORE GUIDES GRADE 4

MATHEMATICS UTAH CORE GUIDES GRADE 4 MATHEMATICS UTAH CORE GUIDES GRADE 4 UTAH STATE BOARD OF EDUCATION 250 EAST 500 SOUTH P.O. BOX 144200 SALT LAKE CITY, UTAH 84114-4200 SYDNEE DICKSON, Ed.D., STATE SUPERINTENDENT OF PUBLIC INSTRUCTION Operations

More information