chapter 2: beginning the problem-solving process introduction to programming with c++ fourth edition
TRANSCRIPT
![Page 1: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/1.jpg)
Chapter 2:Beginning the Problem-Solving
Process
Introduction to Programming with C++
Fourth Edition
![Page 2: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/2.jpg)
Introduction to Programming with C++, Fourth Edition 2
Objectives
• Explain the problem-solving process used to create a computer program
• Analyze a problem• Complete an IPO chart• Plan an algorithm using pseudocode and
flowcharts• Desk-check an algorithm
![Page 3: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/3.jpg)
Introduction to Programming with C++, Fourth Edition 3
Problem Solving/Solving Everyday Problems
• Steps include:– Analysis
– Planning
– Review
– Implementation
– Evaluation
– Modification
![Page 4: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/4.jpg)
Introduction to Programming with C++, Fourth Edition 4
Analysis and Planning
![Page 5: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/5.jpg)
Introduction to Programming with C++, Fourth Edition 5
Modified Algorithm
![Page 6: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/6.jpg)
Introduction to Programming with C++, Fourth Edition 6
Creating Computer Solutions to Problems
![Page 7: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/7.jpg)
Introduction to Programming with C++, Fourth Edition 7
Analyzing the Problem
• Purpose of analyzing the problem:– to determine the goal
– to determine the items needed to achieve the goal
![Page 8: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/8.jpg)
Introduction to Programming with C++, Fourth Edition 8
Analyzing the Problem (continued)
![Page 9: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/9.jpg)
Introduction to Programming with C++, Fourth Edition 9
IPO (Input, Processing, Output) Charts
• Used by programmers to organize and summarize the results of a problem analysis
• To determine input:– Search the problem specification for an answer to
the following question: What information will the computer need to know to print, display, or store the output items?
![Page 10: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/10.jpg)
Introduction to Programming with C++, Fourth Edition 10
IPO Chart with Input and Output
![Page 11: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/11.jpg)
Introduction to Programming with C++, Fourth Edition 11
Determining Important Information
• If you are not sure if a piece of information is important, ask yourself this question: If I didn’t know this information, could I still solve the problem?
• When reading a problem specification, it helps to use a pencil to lightly cross out unnecessary information
![Page 12: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/12.jpg)
Introduction to Programming with C++, Fourth Edition 12
Problem Specification
![Page 13: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/13.jpg)
Introduction to Programming with C++, Fourth Edition 13
Problem Specification Lacking Information
![Page 14: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/14.jpg)
Introduction to Programming with C++, Fourth Edition 14
Problem Specification with Input not Stated
![Page 15: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/15.jpg)
Introduction to Programming with C++, Fourth Edition 15
Planning the Algorithm
• Processing item - an intermediate value that the algorithm uses when processing the input into the output
• Pseudocode - a tool programmers use to help them plan an algorithm
• Flowchart - uses standardized symbols to show the steps the computer needs to take to accomplish the program’s goal
![Page 16: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/16.jpg)
Introduction to Programming with C++, Fourth Edition 16
Completed IPO Chart
![Page 17: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/17.jpg)
Introduction to Programming with C++, Fourth Edition 17
IPO Chart with Flow Chart
![Page 18: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/18.jpg)
Introduction to Programming with C++, Fourth Edition 18
Flowchart Symbols
• Flowlines - used to connect symbols
• Start/stop symbol (oval) – indicates beginning of flowchart
• Process symbols (rectangles) – used to represent tasks such as calculations
• Input/output symbol (parallelogram) - used to represent input tasks
![Page 19: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/19.jpg)
Introduction to Programming with C++, Fourth Edition 19
Solving Sarah’s Problem
![Page 20: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/20.jpg)
Introduction to Programming with C++, Fourth Edition 20
IPO Chart for Problem Specification
![Page 21: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/21.jpg)
Introduction to Programming with C++, Fourth Edition 21
Hints for Planning Algorithms
![Page 22: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/22.jpg)
Introduction to Programming with C++, Fourth Edition 22
Desk-Checking the Algorithm
• Reasons for desk-checking:– To verify that the program is not missing any
steps
– To verify that the existing steps are correct and in the proper order
![Page 23: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/23.jpg)
Introduction to Programming with C++, Fourth Edition 23
Desk-Check Table with New Weekly Pay
![Page 24: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/24.jpg)
Introduction to Programming with C++, Fourth Edition 24
Results of Second Desk-Check
![Page 25: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/25.jpg)
Introduction to Programming with C++, Fourth Edition 25
The Gas Mileage Problem
![Page 26: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/26.jpg)
Introduction to Programming with C++, Fourth Edition 26
The Gas Mileage Problem (continued)
• Analyze the problem looking for nouns and adjectives that represent both input and output
• Output should answer the following question: What does the user want to see printed on paper, displayed on the screen, or stored in a file?
• Input should answer the following question: What information will the computer need to know to print, display, or store the output items?
![Page 27: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/27.jpg)
Introduction to Programming with C++, Fourth Edition 27
IPO Chart
![Page 28: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/28.jpg)
Introduction to Programming with C++, Fourth Edition 28
Completed Desk-Check Table
![Page 29: Chapter 2: Beginning the Problem-Solving Process Introduction to Programming with C++ Fourth Edition](https://reader033.vdocument.in/reader033/viewer/2022061520/56649e7c5503460f94b7d85e/html5/thumbnails/29.jpg)
Introduction to Programming with C++, Fourth Edition 29
Summary
• Explain the problem-solving process used to create a computer program
• Complete an IPO chart• Use algorithms (pseudocode) and flowcharts• Use desk-checking techniques