SlideShare a Scribd company logo
1 of 42
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
An Introduction to Programming with C++
Eighth Edition
Chapter 2:
Beginning the Problem-Solving Process
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
• 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
Chapter Objectives
2An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
• People solve hundreds of simple problems every day
without thinking about how they do it
• Understanding the thought process involved can help in
solving more complex problems
• You can also use a similar process to design a computer
solution to a problem (computer program)
Problem Solving
3An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
• First step in solving a problem: analyze it
– Example: paying and mailing a bill
• Next, you plan, review, implement, and evaluate the
solution
• After this, it may be necessary to modify the solution
Solving Everyday Problems
4An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
Solving Everyday Problems (cont’d.)
Figure 2-1 Summary of the analysis and planning steps for
the bill paying problem
5An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
Solving Everyday Problems (cont’d.)
Figure 2-2 Modified algorithm for the bill paying problem
6An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
• A similar process to everyday problem solving is used to
create computer programs
• A computer program is a solution implemented on a
computer
• There are six steps to creating a computer solution to a
problem
Creating Computer Solutions to Problems
7An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
Creating Computer Solutions to Problems
(cont’d.)
Figure 2-3 How to create a computer solution to a problem
8An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
• It is essential to understand a problem before creating a
solution to it
• Analyze a problem to:
– Determine the goal of solving it (Output)
– Determine the items needed to achieve that goal (Input)
• Always search first for the output
Step 1−Analyzing the Problem
9An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
Step 1−Analyzing the Problem (cont’d.)
Figure 2-4 Problem specification for Addison O’Reilly
10An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
• Some programmers use an IPO chart to organize and
summarize the results of a problem analysis
– IPO: Input, processing, and output
Step 1−Analyzing the Problem (cont’d.)
Figure 2-5 Partially completed IPO chart
showing the input and output items
11An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
• Several readings of the problem may be necessary to
fully understand the problem
• Cross out irrelevant information in the problem
description
Hints for Analyzing Problems
Figure 2-6 Problem specification with
unimportant information crossed out
12An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
• Some problem specifications contain incomplete
information
Hints for Analyzing Problems (cont’d.)
Figure 2-7 Problem specification that does
not contain enough information
13An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
• Distinguish between information that is missing and
information that is implied
Hints for Analyzing Problems (cont’d.)
Figure 2-8 Problem specification in
which the input is not explicitly stated
14An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
• Algorithm: set of instructions that will transform the
problem’s input into its output
– Record in the Processing column of the IPO chart
– Can be written as pseudocode or a flowchart
• Pseudocode: tool programmers use to help plan an
algorithm
– Short English statements
– Not standardized
– Not understandable by a computer
Step 2−Planning the Algorithm
15An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
Step 2−Planning the Algorithm (cont’d.)
Figure 2-9 Problem specification and IPO
chart for the Addison O’Reilly problem
16An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
• Flowcharts are also used to plan an algorithm
– Use standardized symbols
– Symbols connected with flowlines
– Oval: start/stop symbol
• Represents beginning and end of algorithm
– Rectangle: process symbol
• Represents tasks such as calculations
– Parallelogram: input/output symbol
• Represents I/O tasks
Step 2−Planning the Algorithm (cont’d.)
17An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
Figure 2-10 Figure 2-9’s algorithm in flowchart form
18An Introduction to Programming with C++, Eighth Edition
Step 2−Planning the Algorithm (cont’d.)
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
Step 2−Planning the Algorithm (cont’d.)
Figure 2-11 A different solution to the
Addison O’Reilly problem (pseudocode)
19An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
• Processing item: an intermediate
value (neither input nor output)
the algorithm uses to transform
input into output
Step 2−Planning the Algorithm (cont’d.)
Figure 2-11 A different solution to the
Addison O’Reilly problem (flowchart)
20An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
Step 3−Desk-Checking the Algorithm
• Desk-checking an algorithm verifies that it is correct
– Refers to checking an algorithm by hand, rather than
with a computer
– Also called hand-tracing
• Choose sample data and manually compute the expected
output value
• Creating a desk-check table can be helpful
21An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
Step 3−Desk-Checking the Algorithm
(cont’d.)
Figure 2-12 Manual cost calculation for the first desk-check
22An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
Step 3−Desk-Checking the Algorithm
(cont’d.)
Figure 2-13 Addison O’Reilly solution and
partially completed desk-check table
23An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
Step 3−Desk-Checking the Algorithm
(cont’d.)
Figure 2-14 Input values entered in the desk-check table
Figure 2-16 Output value entered in the desk-check table
24An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
Step 3−Desk-Checking the Algorithm
(cont’d.)
Figure 2-17 Manual cost calculation for
the second desk-check
25An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
Figure 2-19 Value of the second desk-check’s
processing item entered in the desk-check table
Figure 2-20 Value of the second desk-check’s
output item entered in the desk-check table
Figure 2-18 Second set of input values
entered in the desk-check table
26An Introduction to Programming with C++, Eighth Edition
Step 3−Desk-Checking the Algorithm
(cont’d.)
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
• Valid data: data that the algorithm is expecting the user
to enter
• Invalid data: data that the algorithm is not expecting
the user to enter
• You should test an algorithm with invalid data
– Users may make mistakes when entering data
Step 3−Desk-Checking the Algorithm
(cont’d.)
27An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
The Gas Mileage Problem
Figure 2-21 Problem specification for the gas mileage problem
28An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
The Gas Mileage Problem (cont’d.)
• Plan the algorithm with an IPO chart
Figure 2-22 IPO chart for the gas mileage problem
29An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
• Then desk-check the algorithm
The Gas Mileage Problem (cont’d.)
Figure 2-23 Desk-check table for the gas mileage problem
30An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
• Problem solving typically involves analyzing the
problem and then planning, reviewing, implementing,
evaluating, and modifying (if necessary) the solution
• Programmers use tools (IPO charts, pseudocode,
flowcharts) to help them analyze problems and develop
algorithms
• The first step in problem solving is to analyze the
problem
– First determine the output and then the input
Summary
31An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
• The second step is to plan the algorithm
– Write the steps that will transform the input into the
output
– Most algorithms begin with entering input data, then
processing the data, then displaying the output
• The third step is to desk-check the algorithm
– Choose sample data and manually compute the expected
output
– Create a desk-check table to fill in values step by step
Summary (cont’d.)
32An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
Study the IPO chart shown in Figure 2-26 and then answer
the questions.
Lab 2-1: Stop and Analyze
Figure 2-26 IPO chart for Lab 2-1
33An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
• Complete the desk-check table using two sets of input
values. First, use 100, 5, and 8 as the quantity sold, item
cost, and item selling price, respectively. The use 650,
2.50, and 3.75. What will the algorithm display using
the first set of input values? What will the algorithm
display using the second set of input values?
• How would you modify the IPO chart to also display the
difference between the item cost and item selling
price?
• How would you modify the IPO chart and desk-check
table to eliminate the use of a processing item?
Lab 2-1: Stop and Analyze (cont’d.)
34An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
• Create an algorithm for the manager of the Jericho
Bakery
Lab 2-2: Plan and Create
Figure 2-27 Problem Specification for Lab 2-2
35An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
Lab 2-2: Plan and Create (cont’d.)
Figure 2-29 Completed IPO Chart for Lab 2-2
36An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
Lab 2-2: Plan and Create (cont’d.)
Figure 2-30 Manual calculations for the two desk-checks
37An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
• Jericho Bakery has raised the price of its muffins from
$0.50 to $0.55.
• Make the appropriate modifications to the IPO chart
shown earlier in Figure 2-29.
• Desk-check the algorithm twice.
• For the first desk-check, use 4, 2, 0.50, and 0.55 as the
number of doughnuts ordered, number of muffins
ordered, doughnut price, and muffin price, respectively.
• For the second desk-check, use 0, 12, 0.60, and 0.70.
Lab 2-3: Modify
38An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
A local club sells boxes of three types of cookies:
shortbread, pecan sandies, and chocolate mint. The
club leader wants a program that displays the
percentage that each of the cookie types contributes to
the total cookie sales. Figure 2-34 contains a list of
items and instructions that you can use for this lab. Fill
in the IPO chart and determine whether any items are
missing from the list. Next, put the instructions in the
proper order and determine the one or more missing
instructions.
Lab 2-4: What’s Missing?
39An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
Lab 2-4: What’s Missing? (cont’d.)
40An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
The algorithm in Figure 2-35 displays three suggested amounts
to tip a waiter. Desk-check the algorithm twice. First, use
$102.50 and $5.80 as the bill amount and sales tax,
respectively. Then, use $56.78 and $2.18.
Lab 2-5: Desk-Check
Figure 2-35 IPO chart for Lab 2-5
41An Introduction to Programming with C++, Eighth Edition
© 2016 Cengage Learning®. May not be scanned, copied or
duplicated, or posted to a publicly accessible website, in whole
or in part.
The algorithm below should calculate and display the average
of three numbers, but it is not working properly. In this lab,
you will find and correct the errors in the algorithm.
Lab 2-6: Debug
Figure 2-36 IPO chart for Lab 2-6
42An Introduction to Programming with C++, Eighth Edition

More Related Content

What's hot

Program logic and design
Program logic and designProgram logic and design
Program logic and designChaffey College
 
4 evolution-of-programming-languages
4 evolution-of-programming-languages4 evolution-of-programming-languages
4 evolution-of-programming-languagesRohit Shrivastava
 
Logic Formulation 1
Logic Formulation 1Logic Formulation 1
Logic Formulation 1deathful
 
Functions in c++
Functions in c++Functions in c++
Functions in c++Maaz Hasan
 
CS106 Lab 6 - While and Do..While loop
CS106 Lab 6 - While and Do..While loopCS106 Lab 6 - While and Do..While loop
CS106 Lab 6 - While and Do..While loopNada Kamel
 
Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language Md. Imran Hossain Showrov
 
Software re engineering
Software re engineeringSoftware re engineering
Software re engineeringdeshpandeamrut
 
C language industrial training report
C language industrial training reportC language industrial training report
C language industrial training reportRaushan Pandey
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT03062679929
 
Introduction to Pseudocode
Introduction to PseudocodeIntroduction to Pseudocode
Introduction to PseudocodeDamian T. Gordon
 
Intro to programming and how to start that career
Intro to programming and how to start that careerIntro to programming and how to start that career
Intro to programming and how to start that careerTarek Alabd
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchartSachin Goyani
 

What's hot (20)

Program logic and design
Program logic and designProgram logic and design
Program logic and design
 
C++ programming
C++ programmingC++ programming
C++ programming
 
Standard Library Functions
Standard Library FunctionsStandard Library Functions
Standard Library Functions
 
4 evolution-of-programming-languages
4 evolution-of-programming-languages4 evolution-of-programming-languages
4 evolution-of-programming-languages
 
Component based software engineering
Component based software engineeringComponent based software engineering
Component based software engineering
 
Logic Formulation 1
Logic Formulation 1Logic Formulation 1
Logic Formulation 1
 
Presentation on C programming language
Presentation on C programming languagePresentation on C programming language
Presentation on C programming language
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
CS106 Lab 6 - While and Do..While loop
CS106 Lab 6 - While and Do..While loopCS106 Lab 6 - While and Do..While loop
CS106 Lab 6 - While and Do..While loop
 
Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language
 
C/C++ History in few slides
C/C++ History in few slides C/C++ History in few slides
C/C++ History in few slides
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
 
Software re engineering
Software re engineeringSoftware re engineering
Software re engineering
 
C language industrial training report
C language industrial training reportC language industrial training report
C language industrial training report
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
 
Introduction to Pseudocode
Introduction to PseudocodeIntroduction to Pseudocode
Introduction to Pseudocode
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
 
Intro to programming and how to start that career
Intro to programming and how to start that careerIntro to programming and how to start that career
Intro to programming and how to start that career
 
string in C
string in Cstring in C
string in C
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 

Viewers also liked

Treffinger power point
Treffinger power pointTreffinger power point
Treffinger power pointadyawman
 
Flowchart symbols
Flowchart symbolsFlowchart symbols
Flowchart symbolsgiz82
 
Design thinking as a creative problem solving process - Part 1
Design thinking as a creative problem solving process - Part 1Design thinking as a creative problem solving process - Part 1
Design thinking as a creative problem solving process - Part 1Peer Academy
 
Problem Solving Tools and Techniques by TQMI
Problem Solving Tools and Techniques by TQMIProblem Solving Tools and Techniques by TQMI
Problem Solving Tools and Techniques by TQMITQMI
 
Presentation on diagram and flowchart
Presentation on diagram and flowchartPresentation on diagram and flowchart
Presentation on diagram and flowchartSwarnima Tiwari
 
Flow chart powerpoint presentation slides ppt templates
Flow chart powerpoint presentation slides ppt templatesFlow chart powerpoint presentation slides ppt templates
Flow chart powerpoint presentation slides ppt templatesSlideTeam.net
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and FlowchartsDeva Singh
 
Problem Solving PowerPoint PPT Content Modern Sample
Problem Solving PowerPoint PPT Content Modern SampleProblem Solving PowerPoint PPT Content Modern Sample
Problem Solving PowerPoint PPT Content Modern SampleAndrew Schwartz
 

Viewers also liked (12)

Treffinger power point
Treffinger power pointTreffinger power point
Treffinger power point
 
Ch02
Ch02Ch02
Ch02
 
Chapter 02 - Problem Solving
Chapter 02 - Problem SolvingChapter 02 - Problem Solving
Chapter 02 - Problem Solving
 
Flowchart symbols
Flowchart symbolsFlowchart symbols
Flowchart symbols
 
Introduction to problem solving in C
Introduction to problem solving in CIntroduction to problem solving in C
Introduction to problem solving in C
 
Design thinking as a creative problem solving process - Part 1
Design thinking as a creative problem solving process - Part 1Design thinking as a creative problem solving process - Part 1
Design thinking as a creative problem solving process - Part 1
 
Problem Solving Tools and Techniques by TQMI
Problem Solving Tools and Techniques by TQMIProblem Solving Tools and Techniques by TQMI
Problem Solving Tools and Techniques by TQMI
 
Flow charts
Flow chartsFlow charts
Flow charts
 
Presentation on diagram and flowchart
Presentation on diagram and flowchartPresentation on diagram and flowchart
Presentation on diagram and flowchart
 
Flow chart powerpoint presentation slides ppt templates
Flow chart powerpoint presentation slides ppt templatesFlow chart powerpoint presentation slides ppt templates
Flow chart powerpoint presentation slides ppt templates
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
 
Problem Solving PowerPoint PPT Content Modern Sample
Problem Solving PowerPoint PPT Content Modern SampleProblem Solving PowerPoint PPT Content Modern Sample
Problem Solving PowerPoint PPT Content Modern Sample
 

Similar to Chapter 2 - Beginning the Problem-Solving Process

Chapter 9 Value-Returning Functions
Chapter 9 Value-Returning FunctionsChapter 9 Value-Returning Functions
Chapter 9 Value-Returning Functionsmshellman
 
Chapter 6 - More on the Selection Structure
Chapter 6 - More on the Selection StructureChapter 6 - More on the Selection Structure
Chapter 6 - More on the Selection Structuremshellman
 
Lecture 1 programming fundamentals (PF)
Lecture 1 programming fundamentals (PF)Lecture 1 programming fundamentals (PF)
Lecture 1 programming fundamentals (PF)Kamran Zafar
 
Chapter 7 - The Repetition Structure
Chapter 7 - The Repetition StructureChapter 7 - The Repetition Structure
Chapter 7 - The Repetition Structuremshellman
 
Project 12 power point
Project 12 power pointProject 12 power point
Project 12 power pointaggie519
 
CIS 170 Focus Dreams/newtonhelp.com
CIS 170 Focus Dreams/newtonhelp.comCIS 170 Focus Dreams/newtonhelp.com
CIS 170 Focus Dreams/newtonhelp.combellflower82
 
CIS 170 Life of the Mind/newtonhelp.com   
CIS 170 Life of the Mind/newtonhelp.com   CIS 170 Life of the Mind/newtonhelp.com   
CIS 170 Life of the Mind/newtonhelp.com   llflowe
 
CIS 170 Imagine Your Future/newtonhelp.com   
CIS 170 Imagine Your Future/newtonhelp.com   CIS 170 Imagine Your Future/newtonhelp.com   
CIS 170 Imagine Your Future/newtonhelp.com   bellflower42
 
Cis 170 Extraordinary Success/newtonhelp.com
Cis 170 Extraordinary Success/newtonhelp.com  Cis 170 Extraordinary Success/newtonhelp.com
Cis 170 Extraordinary Success/newtonhelp.com amaranthbeg143
 
Computer programming all chapters
Computer programming all chaptersComputer programming all chapters
Computer programming all chaptersIbrahim Elewah
 

Similar to Chapter 2 - Beginning the Problem-Solving Process (20)

Lesson 6.2 logic error
Lesson  6.2 logic errorLesson  6.2 logic error
Lesson 6.2 logic error
 
Chapter 9 Value-Returning Functions
Chapter 9 Value-Returning FunctionsChapter 9 Value-Returning Functions
Chapter 9 Value-Returning Functions
 
Lesson 7.2 using counters and accumulators
Lesson 7.2 using counters and accumulatorsLesson 7.2 using counters and accumulators
Lesson 7.2 using counters and accumulators
 
Lesson 9.2 guessing the game program
Lesson 9.2 guessing the game programLesson 9.2 guessing the game program
Lesson 9.2 guessing the game program
 
Lesson 8 more on repitition structure
Lesson 8 more on repitition structureLesson 8 more on repitition structure
Lesson 8 more on repitition structure
 
Chapter 6 - More on the Selection Structure
Chapter 6 - More on the Selection StructureChapter 6 - More on the Selection Structure
Chapter 6 - More on the Selection Structure
 
Lesson 9.1 value returning
Lesson 9.1 value returningLesson 9.1 value returning
Lesson 9.1 value returning
 
Lecture 1 programming fundamentals (PF)
Lecture 1 programming fundamentals (PF)Lecture 1 programming fundamentals (PF)
Lecture 1 programming fundamentals (PF)
 
Lesson 7.1 repitition structure
Lesson 7.1 repitition structureLesson 7.1 repitition structure
Lesson 7.1 repitition structure
 
Chapter 7 - The Repetition Structure
Chapter 7 - The Repetition StructureChapter 7 - The Repetition Structure
Chapter 7 - The Repetition Structure
 
Lesson 6.1 more on selection structure
Lesson 6.1 more on selection structureLesson 6.1 more on selection structure
Lesson 6.1 more on selection structure
 
Lesson 1 introduction to programming
Lesson 1 introduction to programmingLesson 1 introduction to programming
Lesson 1 introduction to programming
 
Project 12 power point
Project 12 power pointProject 12 power point
Project 12 power point
 
Lesson 2 beginning the problem solving process
Lesson 2 beginning the problem solving processLesson 2 beginning the problem solving process
Lesson 2 beginning the problem solving process
 
CIS 170 Focus Dreams/newtonhelp.com
CIS 170 Focus Dreams/newtonhelp.comCIS 170 Focus Dreams/newtonhelp.com
CIS 170 Focus Dreams/newtonhelp.com
 
CIS 170 Life of the Mind/newtonhelp.com   
CIS 170 Life of the Mind/newtonhelp.com   CIS 170 Life of the Mind/newtonhelp.com   
CIS 170 Life of the Mind/newtonhelp.com   
 
CIS 170 Imagine Your Future/newtonhelp.com   
CIS 170 Imagine Your Future/newtonhelp.com   CIS 170 Imagine Your Future/newtonhelp.com   
CIS 170 Imagine Your Future/newtonhelp.com   
 
Cis 170 Extraordinary Success/newtonhelp.com
Cis 170 Extraordinary Success/newtonhelp.com  Cis 170 Extraordinary Success/newtonhelp.com
Cis 170 Extraordinary Success/newtonhelp.com
 
Computer programming all chapters
Computer programming all chaptersComputer programming all chapters
Computer programming all chapters
 
lecture 5
 lecture 5 lecture 5
lecture 5
 

Recently uploaded

Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 

Recently uploaded (20)

Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 

Chapter 2 - Beginning the Problem-Solving Process

  • 1. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. An Introduction to Programming with C++ Eighth Edition Chapter 2: Beginning the Problem-Solving Process
  • 2. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • 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 Chapter Objectives 2An Introduction to Programming with C++, Eighth Edition
  • 3. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • People solve hundreds of simple problems every day without thinking about how they do it • Understanding the thought process involved can help in solving more complex problems • You can also use a similar process to design a computer solution to a problem (computer program) Problem Solving 3An Introduction to Programming with C++, Eighth Edition
  • 4. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • First step in solving a problem: analyze it – Example: paying and mailing a bill • Next, you plan, review, implement, and evaluate the solution • After this, it may be necessary to modify the solution Solving Everyday Problems 4An Introduction to Programming with C++, Eighth Edition
  • 5. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Solving Everyday Problems (cont’d.) Figure 2-1 Summary of the analysis and planning steps for the bill paying problem 5An Introduction to Programming with C++, Eighth Edition
  • 6. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Solving Everyday Problems (cont’d.) Figure 2-2 Modified algorithm for the bill paying problem 6An Introduction to Programming with C++, Eighth Edition
  • 7. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • A similar process to everyday problem solving is used to create computer programs • A computer program is a solution implemented on a computer • There are six steps to creating a computer solution to a problem Creating Computer Solutions to Problems 7An Introduction to Programming with C++, Eighth Edition
  • 8. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Creating Computer Solutions to Problems (cont’d.) Figure 2-3 How to create a computer solution to a problem 8An Introduction to Programming with C++, Eighth Edition
  • 9. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • It is essential to understand a problem before creating a solution to it • Analyze a problem to: – Determine the goal of solving it (Output) – Determine the items needed to achieve that goal (Input) • Always search first for the output Step 1−Analyzing the Problem 9An Introduction to Programming with C++, Eighth Edition
  • 10. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Step 1−Analyzing the Problem (cont’d.) Figure 2-4 Problem specification for Addison O’Reilly 10An Introduction to Programming with C++, Eighth Edition
  • 11. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • Some programmers use an IPO chart to organize and summarize the results of a problem analysis – IPO: Input, processing, and output Step 1−Analyzing the Problem (cont’d.) Figure 2-5 Partially completed IPO chart showing the input and output items 11An Introduction to Programming with C++, Eighth Edition
  • 12. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • Several readings of the problem may be necessary to fully understand the problem • Cross out irrelevant information in the problem description Hints for Analyzing Problems Figure 2-6 Problem specification with unimportant information crossed out 12An Introduction to Programming with C++, Eighth Edition
  • 13. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • Some problem specifications contain incomplete information Hints for Analyzing Problems (cont’d.) Figure 2-7 Problem specification that does not contain enough information 13An Introduction to Programming with C++, Eighth Edition
  • 14. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • Distinguish between information that is missing and information that is implied Hints for Analyzing Problems (cont’d.) Figure 2-8 Problem specification in which the input is not explicitly stated 14An Introduction to Programming with C++, Eighth Edition
  • 15. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • Algorithm: set of instructions that will transform the problem’s input into its output – Record in the Processing column of the IPO chart – Can be written as pseudocode or a flowchart • Pseudocode: tool programmers use to help plan an algorithm – Short English statements – Not standardized – Not understandable by a computer Step 2−Planning the Algorithm 15An Introduction to Programming with C++, Eighth Edition
  • 16. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Step 2−Planning the Algorithm (cont’d.) Figure 2-9 Problem specification and IPO chart for the Addison O’Reilly problem 16An Introduction to Programming with C++, Eighth Edition
  • 17. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • Flowcharts are also used to plan an algorithm – Use standardized symbols – Symbols connected with flowlines – Oval: start/stop symbol • Represents beginning and end of algorithm – Rectangle: process symbol • Represents tasks such as calculations – Parallelogram: input/output symbol • Represents I/O tasks Step 2−Planning the Algorithm (cont’d.) 17An Introduction to Programming with C++, Eighth Edition
  • 18. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Figure 2-10 Figure 2-9’s algorithm in flowchart form 18An Introduction to Programming with C++, Eighth Edition Step 2−Planning the Algorithm (cont’d.)
  • 19. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Step 2−Planning the Algorithm (cont’d.) Figure 2-11 A different solution to the Addison O’Reilly problem (pseudocode) 19An Introduction to Programming with C++, Eighth Edition
  • 20. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • Processing item: an intermediate value (neither input nor output) the algorithm uses to transform input into output Step 2−Planning the Algorithm (cont’d.) Figure 2-11 A different solution to the Addison O’Reilly problem (flowchart) 20An Introduction to Programming with C++, Eighth Edition
  • 21. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Step 3−Desk-Checking the Algorithm • Desk-checking an algorithm verifies that it is correct – Refers to checking an algorithm by hand, rather than with a computer – Also called hand-tracing • Choose sample data and manually compute the expected output value • Creating a desk-check table can be helpful 21An Introduction to Programming with C++, Eighth Edition
  • 22. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Step 3−Desk-Checking the Algorithm (cont’d.) Figure 2-12 Manual cost calculation for the first desk-check 22An Introduction to Programming with C++, Eighth Edition
  • 23. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Step 3−Desk-Checking the Algorithm (cont’d.) Figure 2-13 Addison O’Reilly solution and partially completed desk-check table 23An Introduction to Programming with C++, Eighth Edition
  • 24. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Step 3−Desk-Checking the Algorithm (cont’d.) Figure 2-14 Input values entered in the desk-check table Figure 2-16 Output value entered in the desk-check table 24An Introduction to Programming with C++, Eighth Edition
  • 25. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Step 3−Desk-Checking the Algorithm (cont’d.) Figure 2-17 Manual cost calculation for the second desk-check 25An Introduction to Programming with C++, Eighth Edition
  • 26. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Figure 2-19 Value of the second desk-check’s processing item entered in the desk-check table Figure 2-20 Value of the second desk-check’s output item entered in the desk-check table Figure 2-18 Second set of input values entered in the desk-check table 26An Introduction to Programming with C++, Eighth Edition Step 3−Desk-Checking the Algorithm (cont’d.)
  • 27. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • Valid data: data that the algorithm is expecting the user to enter • Invalid data: data that the algorithm is not expecting the user to enter • You should test an algorithm with invalid data – Users may make mistakes when entering data Step 3−Desk-Checking the Algorithm (cont’d.) 27An Introduction to Programming with C++, Eighth Edition
  • 28. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. The Gas Mileage Problem Figure 2-21 Problem specification for the gas mileage problem 28An Introduction to Programming with C++, Eighth Edition
  • 29. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. The Gas Mileage Problem (cont’d.) • Plan the algorithm with an IPO chart Figure 2-22 IPO chart for the gas mileage problem 29An Introduction to Programming with C++, Eighth Edition
  • 30. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • Then desk-check the algorithm The Gas Mileage Problem (cont’d.) Figure 2-23 Desk-check table for the gas mileage problem 30An Introduction to Programming with C++, Eighth Edition
  • 31. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • Problem solving typically involves analyzing the problem and then planning, reviewing, implementing, evaluating, and modifying (if necessary) the solution • Programmers use tools (IPO charts, pseudocode, flowcharts) to help them analyze problems and develop algorithms • The first step in problem solving is to analyze the problem – First determine the output and then the input Summary 31An Introduction to Programming with C++, Eighth Edition
  • 32. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • The second step is to plan the algorithm – Write the steps that will transform the input into the output – Most algorithms begin with entering input data, then processing the data, then displaying the output • The third step is to desk-check the algorithm – Choose sample data and manually compute the expected output – Create a desk-check table to fill in values step by step Summary (cont’d.) 32An Introduction to Programming with C++, Eighth Edition
  • 33. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Study the IPO chart shown in Figure 2-26 and then answer the questions. Lab 2-1: Stop and Analyze Figure 2-26 IPO chart for Lab 2-1 33An Introduction to Programming with C++, Eighth Edition
  • 34. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • Complete the desk-check table using two sets of input values. First, use 100, 5, and 8 as the quantity sold, item cost, and item selling price, respectively. The use 650, 2.50, and 3.75. What will the algorithm display using the first set of input values? What will the algorithm display using the second set of input values? • How would you modify the IPO chart to also display the difference between the item cost and item selling price? • How would you modify the IPO chart and desk-check table to eliminate the use of a processing item? Lab 2-1: Stop and Analyze (cont’d.) 34An Introduction to Programming with C++, Eighth Edition
  • 35. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • Create an algorithm for the manager of the Jericho Bakery Lab 2-2: Plan and Create Figure 2-27 Problem Specification for Lab 2-2 35An Introduction to Programming with C++, Eighth Edition
  • 36. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Lab 2-2: Plan and Create (cont’d.) Figure 2-29 Completed IPO Chart for Lab 2-2 36An Introduction to Programming with C++, Eighth Edition
  • 37. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Lab 2-2: Plan and Create (cont’d.) Figure 2-30 Manual calculations for the two desk-checks 37An Introduction to Programming with C++, Eighth Edition
  • 38. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • Jericho Bakery has raised the price of its muffins from $0.50 to $0.55. • Make the appropriate modifications to the IPO chart shown earlier in Figure 2-29. • Desk-check the algorithm twice. • For the first desk-check, use 4, 2, 0.50, and 0.55 as the number of doughnuts ordered, number of muffins ordered, doughnut price, and muffin price, respectively. • For the second desk-check, use 0, 12, 0.60, and 0.70. Lab 2-3: Modify 38An Introduction to Programming with C++, Eighth Edition
  • 39. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. A local club sells boxes of three types of cookies: shortbread, pecan sandies, and chocolate mint. The club leader wants a program that displays the percentage that each of the cookie types contributes to the total cookie sales. Figure 2-34 contains a list of items and instructions that you can use for this lab. Fill in the IPO chart and determine whether any items are missing from the list. Next, put the instructions in the proper order and determine the one or more missing instructions. Lab 2-4: What’s Missing? 39An Introduction to Programming with C++, Eighth Edition
  • 40. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Lab 2-4: What’s Missing? (cont’d.) 40An Introduction to Programming with C++, Eighth Edition
  • 41. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. The algorithm in Figure 2-35 displays three suggested amounts to tip a waiter. Desk-check the algorithm twice. First, use $102.50 and $5.80 as the bill amount and sales tax, respectively. Then, use $56.78 and $2.18. Lab 2-5: Desk-Check Figure 2-35 IPO chart for Lab 2-5 41An Introduction to Programming with C++, Eighth Edition
  • 42. © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. The algorithm below should calculate and display the average of three numbers, but it is not working properly. In this lab, you will find and correct the errors in the algorithm. Lab 2-6: Debug Figure 2-36 IPO chart for Lab 2-6 42An Introduction to Programming with C++, Eighth Edition