COMPUTER PROGRAMMING I Understand Problem Solving Tools to Design Programming Solutions.

Slides:



Advertisements
Similar presentations
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 4 Making Decisions in a Program.
Advertisements

PSEUDOCODE & FLOW CHART
Chapter 1 - An Introduction to Computers and Problem Solving
Chapter 2 - Problem Solving
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 9 Decisions, Decisions, Decisions.
Reference :Understanding Computers
Chapter 2 - Problem Solving
Basics of Computer Programming Web Design Section 8-1.
Chapter 2- Visual Basic Schneider
Chapter 2: Algorithm Discovery and Design
Program Design and Development
Developing logic (Examples on algorithm and flowchart)
Chapter 2: Algorithm Discovery and Design
Chapter 2: Algorithm Discovery and Design
Chapter 3 Planning Your Solution
The Program Design Phases
CSC103: Introduction to Computer and Programming
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
Flow Charting. Goals Create Algorithms using Flow Charting procedures. Distinguish between Flow Charting and Pseudocode. Top-Down Design Bottom-up Design.
Computer Programming TCP1224 Chapter 2 Beginning the Problem-Solving Process.
Invitation to Computer Science, Java Version, Second Edition.
The Logical Structure of Algorithms. Algorithms Steps necessary to complete a task or solve a problem. Example: Recipe for baking a cake –Will contain.
PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.
Introduction to Programming Design School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 1, Friday 01/17/2003) (Continued)
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
Chapter 1 Introduction to Structured Design. Introduction  System  A combination of people, equipment, and procedures that work together to perform.
Software Life Cycle What Requirements Gathering, Problem definition
Conditions. Objectives  Understanding what altering the flow of control does on programs and being able to apply thee to design code  Look at why indentation.
INTRODUCTION TO COMPUTING CHAPTER NO. 04. Programming Languages Program Algorithms and Pseudo Code Properties and Advantages of Algorithms Flowchart (Symbols.
Control Structures II Repetition (Loops). Why Is Repetition Needed? How can you solve the following problem: What is the sum of all the numbers from 1.
Pseudocode Simple Program Design Third Edition A Step-by-Step Approach 2.
Flowcharts and Algorithms. Review of Terms  A computer is a machine that can represent and manipulate data –Ultimately the data and the instructions.
ITEC113 Algorithms and Programming Techniques
Computer Programming I Summer 2011
(C)opyright 2000 Scott/Jones Publishers Introduction to Flowcharting.
Fundamentals of Algorithms MCS - 2 Lecture # 5. Representation of Algorithms (continued) Flowcharts.
Structured Programming (4 Credits)
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '081 Chapter 2 - Problem Solving 2.1 Program Development Cycle 2.2 Programming Tools.
IPC144 Session 4 Flowcharts 1. Objectives: By the end of this session, the student will be able to: List the three elements of the Structure Theorem Identify.
Algorithms and Pseudocode
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
ICS124 Session 9 Flowcharting 1. By the end of this section the student will be able to:  Name the three structures of the Structure Theorem  Identify.
IPC144 Session 4 Flowcharts 1. Objectives: By the end of this session, the student will be able to: List the three elements of the Structure Theorem Identify.
Progression in KS3/4 Algorithms MONDAY 30 TH NOVEMBER SUE SENTANCE.
How Computers Solve Problems Computers also use Algorithms to solve problems, and change data into information Computers can only perform one simple step.
Flow Charts And Pseudo Codes Grade 12. An algorithm is a complete step-by- step procedure for solving a problem or accomplishing a task.
Problem Solving Flowcharts. Flowcharts Introduction  Flowcharts allow us to create a visual representation of a solution to a problem DRAW  With flowcharts,
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
Algorithms and Flowcharts
Learning outcomes 5 Developing Code – Using Flowcharts
Understand Problem Solving Tools to Design Programming Solutions
Basics of Computer Programming
Understand Problem Solving Tools to Design Programming Solutions
Basics of Computer Programming
Basics of Computer Programming
Basics of Computer Programming
Programming Fundamentals
Creating Flowcharts AIM:
Unit# 9: Computer Program Development
Problem-Solving and Control Structures By Faith Brenner
Computational Thinking for KS3
Chapter 2- Visual Basic Schneider
Problem-Solving and Control Structures By Faith Brenner
ICT Programming Lesson 3:
ICT Gaming Lesson 2.
Basic Concepts of Algorithm
WJEC GCSE Computer Science
Programming Logic and Design Eighth Edition
Presentation transcript:

COMPUTER PROGRAMMING I Understand Problem Solving Tools to Design Programming Solutions

Objective/Essential Standard 2 Essential Standard: 2.00 Understand the Solution Development Process Indicator: 2.02 Understand Problem Solving Tools to Design Programming Solutions. (3%)

Problem Solving Tools Programs are created to solve problems. A solution must be designed prior to coding. One method of designing a solution to a problem is to create an algorithm.

Algorithms An algorithm is a list of steps to solve a problem written in plain English.  Steps to solve a problem are written out and numbered in the order in which they should be executed. They should be as extensive as necessary to outline the solution. Your algorithm is not only going to tell your program what to do but how to do it.

Algorithm Example – Going Home The Walk Algorithm 1. Leave classroom 2. Turn right out of school building 3. Walk 1.2 miles 4. Turn right on street 5. Go to 4 th house The Bus Algorithm 1. Go to the bus area 2. Get in right bus 3. Go to house

Algorithms Both algorithms, and others that accomplish the same task (of getting you home). There are advantages and disadvantages associated with each option. You have to consider each option and its advantages/disadvantages before you choose the algorithm you want to continue developing into your program.

Programming Algorithm Example Simple steps representing a process for dealing with a guessing game in which the computer generates a random number and the player guesses. 1. Generate a secret random number between 1 and Get a number from the player. 3. Compare the player’s guess to the secret number. 4. Compare the numbers. If the numbers are identical, go to step 5. Otherwise, tell the player the number was either too high and return to step Display a message stating the secret number was guessed.

Pseudocode Pseudocode is a mix of English language and code that represents what you want your program to do. It helps you determine how you want the program to work as well as what variables and methods/functions you will want to include. Developing pseudocode will help you work through your logic, reducing the number of errors and potential re-writes you will have to do.

Pseudocode Example Represents the same process for dealing with a guessing game in which the computer generates a random number and the player guesses the number Sub btnCheckGuess_Click() randomNumber = 37 Get playerGuess from text box If playerGuess = randomNumber Then Display “Correct” ElseIf playerGuess < randomNumber Then Display “Guess too Low” Else Display “Guess too High” End Sub

Flowchart A third tool in programming is through the use of a flowchart. Flowcharts use symbols and text to give a visual representation of a solution to a problem. The direction of the arrows indicates the flow of the logic.

Flowchart Flowcharts help the programmer begin to plan the programming project. They provide a visual representation of the algorithm or process. They describe the inputs, processes and outputs of the program that are needed to successfully complete the project.

Flowchart Symbols There are many flowchart programs, however you can also use Microsoft Word to create a flowchart – or just a piece of paper and a pencil. To create the flowchart, there are different symbols that represent the various parts. We will only use a few of these symbols. Use lines with arrows to indicate flow of control. The text in your flowchart symbols is your pseudocode.

Flowchart Symbols Start/End Input/Output Processes Decisions Ovals : Start should always be the first shape, with a End at the end of the flow chart or a process. Parallelogram: This shape is used to show raw materials used for ‘ingredients’ and to show the finished product. Input/Output – Get/Display Rectangles should be used to show processes/commands, eg. ‘Bake Cake’. These are activities. Diamonds: Hold questions that resolve into True or False. Used for decisions that divide into two options and to control loops.

Start Input Process A Output Stop Oval Used for Start & Stop Parallelogram: Used for inputs – raw materials Examples: Get Cake Ingredients Plastic, metal Parallelogram: Used for outputs – finished product Examples: Finished cake Car door Parallelogram: Used for outputs – finished product Examples: Finished cake Car door Process B Input Rectangle : Used for all processes Examples: Bake cake, Review music choices or Build wheels Rectangle : Used for all processes Examples: Bake cake, Review music choices or Build wheels Sequence Logic Structure Commands one after another

Structured Programming A technique that has proven to be very effective in solving programs as well as in modifying solutions. The principles of structured programming are fundamental to procedure-oriented programming. They are also relevant to object-oriented programming.

Structured Programming Structured programming is the ability to express a problem solution using only three basic patterns of logic. These patterns are referred to as control structures.  The patterns are based on the computer’s ability to execute instructions in a step-by-step, sequential manner; its ability to make decisions; and its ability to repeat instructions. “Structure theorem” (paper by C. Bohm and G. Jacopini in 1965) – accepted as a proof of the claim that the three structures are sufficient for programming.

Basic Control Structures Three patterns: 1. Simple Sequence control structure 2. Conditional control structure  Decision 3. Iteration control structure  Loops

SIMPLE SEQUENCE Control Structure Represents the computer’s ability to execute instructions in a step-by-step, sequential manner. Example: directions to get to the school – steps must be followed sequentially

SIMPLE SEQUENCE Control Structure 1. Proceed down Main Street for two miles 2. Turn left on Ocean Drive, 3. Proceed on Ocean Drive for three blocks, to the fork. 4. At the fork, take Swan Street to the left. 5. Proceed two blocks. 6. House is second on the left. (246 Swan Street.)

Conditional Control Structure Represents the computer’s ability to make a decision Example: provide alternate directions if there is a blocked intersection.

Start Input -optional Process A Output -optional Process B Stop If Question- answered true or false True (yes)False (no) Conditional (Decision) Logic Structure One time through – one way or the other only End Decision

Start Input Process A Output Process B Stop Used for Start & Stop Used for inputs – raw materials Examples: Cake Ingredients Plastic, metal Used for outputs – finished product Examples: Finished cake Car door Used for all processes Examples: Bake cake Review music choices Build wheels If Process A True (yes) False (no) Used for decision making - Questions Conditional (Decision) Logic Structure End Decision

Conditional (Decision) Logic Structure One time through – one way or the other only

End Decision Decision - Pseudocode and Flowchart Proceed down hall Turn left at first intersecting hallway IF hungry THEN Turn right into the cafeteria ELSE Continue to classroom ENDIf Stop Proceed down hall Turn left at first intersecting hallway Hungry ? Turn right into cafeteria Start Continue to Classroom TF

Iteration Control Structure Represents the computer’s ability to repeat a series of instructions Loop – a series of repeated instructions Infinite loop – instructions that would continue without a way out. Every loop must include a statement that defines how many times to execute the loop steps or under what condition to continue or stop the looping process.

Iteration Control Structure DOWHILE hair is not clean Wash hair Rinse hair ENDDO

End Decision Loop - Pseudocode and Flowchart Proceed down hall Get food in cafeteria DOWHILE hungry Eat END DO Stop Proceed down hall Get food in cafteteria Hungry ? Eat Food Start F T

Input Process A NO PROCESSES ALLOWED HERE!!!! Exit only Stop Used for Start & Stop Used for inputs – raw materials Examples: Cake Ingredients Plastic, metal Used to show where loop stops – required. DOWHILE Question (T or F) True (yes) False (no) Process B Used for decision making - Questions ENDDO Iteration (Loop) Structure Logic

Using Microsoft Word to Create a Flowchart Open Microsoft Word. Under Insert choose Shapes Look down the list until you see Flowchart. Hoover your mouse over a shape, you will see a popup telling you what that shape is used for.

Using Microsoft Word to Create a Flowchart Select and draw the shapes needed for your program logic. Once you draw a shape you can right click and select Add Text to enter information into your symbol. Join your symbols using arrows indicating program data flow.

Iteration (Loop) Structure Logic

Expectations Some general rules:  If you do not understand the problem, you probably will not be able to create a solution.  Remember to start with the solution in mind.  Your program solution should not necessarily look like that of another programmer.  Use your tools to help you determine your solution.