Understand Problem Solving Tools to Design Programming Solutions

Slides:



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

Chapter 1 - An Introduction to Computers and Problem Solving
Chapter 2 - Problem Solving
Reference :Understanding Computers
Chapter 2 - Problem Solving
Basics of Computer Programming Web Design Section 8-1.
Chapter 2- Visual Basic Schneider
Program Design and Development
Chapter 2: Algorithm Discovery and Design
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.
The Logical Structure of Algorithms. Algorithms Steps necessary to complete a task or solve a problem. Example: Recipe for baking a cake –Will contain.
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.
Computer Programming I Summer 2011
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '081 Chapter 2 - Problem Solving 2.1 Program Development Cycle 2.2 Programming Tools.
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.
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.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
Creating Flowcharts Principles of Engineering
Creating a Flowchart Computer Integrated Manufacturing
Learning outcomes 5 Developing Code – Using Flowcharts
ALGORITHMS AND FLOWCHARTS
Understand Problem Solving Tools to Design Programming Solutions
Creating Flowcharts Name of PowerPoint CIM Name of Lesson
FLOWCHARTS Part 1.
Basics of Computer Programming
Chapter 2- Visual Basic Schneider
Programming Mehdi Bukhari.
Introduction To Flowcharting
Basics of Computer Programming
Basics of Computer Programming
Introduction to Computer Programming
Basics of Computer Programming
Programming Fundamentals
Creating Flowcharts Principles of Engineering
Creating Flowcharts AIM:
Microsoft Visual Basic 2005 BASICS
ALGORITHMS AND FLOWCHARTS
Unit# 9: Computer Program Development
Creating Flowcharts Principles of Engineering
Problem-Solving and Control Structures By Faith Brenner
Creating Flowcharts Name of PowerPoint CIM Name of Lesson
Algorithms & Pseudocode
Objectives After studying this chapter, you should be able to:
ALGORITHMS AND FLOWCHARTS
Computational Thinking for KS3
Chapter 2- Visual Basic Schneider
Introduction to Algorithms and Programming
Chapter 2- Visual Basic Schneider
Data and Flowcharts Session
Flowcharting & Algorithms
Problem-Solving and Control Structures By Faith Brenner
ICT Programming Lesson 3:
Data and Flowcharts Session
ICT Gaming Lesson 2.
Creating Flowcharts Name of PowerPoint CIM Name of Lesson
Data and Flowcharts Session
Creating Flowcharts Principles of Engineering
Basic Concepts of Algorithm
WJEC GCSE Computer Science
Creating Flowcharts Principles Of Engineering
Creating Flowcharts Name of PowerPoint CIM Name of Lesson
Programming Logic and Design Eighth Edition
Presentation transcript:

Understand Problem Solving Tools to Design Programming Solutions Computer Programming I

Objective/Essential Standard 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 Leave classroom Turn right out of school building Walk 1.2 miles Turn right on street Go to 4th house The Bus Algorithm Leave the classroom Go to the bus area Get in right bus Get off at your bus stop Go to 4th house

Algorithms Both algorithms, and other possible algorithms (like getting a ride with a friend), 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. (One algorithm may be quicker but the other algorithm may be safer)

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. Computer randomly generated random number between 1 and 100. (The number is unknown to the player) Get a number from the player. Compare the player’s guess to the secret number. If the numbers are identical, go to step 5. Otherwise, tell the player the number was either too high or too low, and return to step 2. 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. Multiline comments are not supported in VB. Each line of the comment must begin with a ' .

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

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

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: Simple Sequence control structure Conditional control structure Decision 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 home from school – steps must be followed sequentially

SIMPLE SEQUENCE Control Structure Proceed down Main Street for two miles Turn left on Ocean Drive, Proceed on Ocean Drive for three blocks, to the fork. At the fork, take Swan Street to the left. Proceed two blocks. 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.

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

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

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

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

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

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

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

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

Some general rules: Expectations 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.