Clearly Visual Basic Programming with Visual Basic 2010
Clearly Visual Basic: Programming with Visual Basic 2010 2 nd Edition Chapter 2 First You Need to Plan the Party (Problem-Solving Process)
Objectives After studying Chapter 2, you should be able to: �Identify the output and input in a problem specification �Plan an algorithm using pseudocode and flowcharts �Desk-check an algorithm 2 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition
How Do Programmers Solve Problems? �You cannot solve a problem unless you understand it �You cannot understand a problem unless you analyze it �Most important components of any problem �Problem’s output and its input 3 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition
How Do Programmers Solve Problems? (cont’d. ) Figure 2 -1 Steps for solving a problem using a computer 4 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition
Step 1 – Analyze the Problem �Identify output �What does the user want to see printed on paper, displayed on the screen, or stored in a file? �Identify input �What information will the computer need to know to print, display, or store the output items? �Analysis step is most difficult problem-solving step 5 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition
Step 1 – Analyze the Problem (cont’d. ) Figure 2 -2 Problem specification for Addison Smith 6 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition
Step 1 – Analyze the Problem (cont’d. ) Figure 2 -3 Output and input items for the Addison Smith problem 7 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition
Step 1 – Analyze the Problem (cont’d. ) Figure 2 -4 Problem specification for Aiden Turner 8 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition
Step 1 – Analyze the Problem (cont’d. ) Figure 2 -5 Output and input items for the Aiden Turner problem 9 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition
Step 2 – Plan the Algorithm �Pseudocode �False code, not standardized �Cannot be understood by a computer �Used by programmers when planning an algorithm �Flowchart �Uses standardized symbols to visually depict an algorithm 10 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition
Step 2 – Plan the Algorithm (cont’d. ) Figure 2 -6 Output, input, and algorithm items for the Addison Smith problem 11 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition
Step 2 – Plan the Algorithm (cont’d. ) �Flowchart symbols �Oval: start/stop symbol �Parallelogram: input/output symbol �Rectangle: process symbol �Flowlines �Connect symbols �Processing item �Intermediate value that algorithm uses when processing input into output 12 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition
Figure 2 -7 Flowchart for the Addison Smith problem’s algorithm 13 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition
Figure 2 -8 Output, input, and algorithm for the Aiden Turner problem 14 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition
Figure 2 -9 A different solution to the Aiden Turner problem 15 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition
Figure 2 -10 Flowchart for the algorithm shown in Figure 2 -9 16 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition
Step 3 – Desk-Check the Algorithm �Desk-checking �Also called hand-tracing �Follow each of the algorithm’s instructions by hand �Choose sample data for input values �Manually compute expected output values �Valid data �Data that algorithm is expecting user to enter �Invalid data �Data that algorithm is not expecting user to enter 17 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition
Figure 2 -11 Addison Smith solution and desk-check table 18 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition
Figure 2 -16 Aiden Turner solution and desk-check table 19 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition
Summary �First three steps in the problem-solving process �Analyze the problem �Plan the algorithm �Desk-check the algorithm �Programmers use tools to organize their thoughts �Pseudocode �Flowcharts 20 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition
Summary (cont’d. ) �Algorithm �Enter data �Process data �Display, print, or store data �Calculation instructions in an algorithm �Specify what is to be calculated and how to perform calculation �After completing analysis and planning steps: �Programmer desk-checks algorithm 21 Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition
- Slides: 21