SlideShare a Scribd company logo
Introduction to Programming in C++
Seventh Edition
Chapter 2:
Beginning the Problem-Solving Process
• 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++, Seventh Edition
• 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++, Seventh Edition
• 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++, Seventh Edition
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++, Seventh Edition
Solving Everyday Problems (cont’d.)
Figure 2-2 Modified algorithm for the bill paying problem
6An Introduction to Programming with C++, Seventh Edition
• 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++, Seventh Edition
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++, Seventh Edition
• 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++, Seventh Edition
Step 1−Analyzing the Problem (cont’d.)
Figure 2-4 Problem specification for Treyson Mobley
10An Introduction to Programming with C++, Seventh Edition
• 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++, Seventh Edition
• 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++, Seventh Edition
• 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++, Seventh Edition
• 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++, Seventh Edition
• 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++, Seventh Edition
Step 2−Planning the Algorithm (cont’d.)
Figure 2-9 Problem specification and IPO
chart for the Treyson Mobley problem
16An Introduction to Programming with C++, Seventh Edition
• 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++, Seventh Edition
Figure 2-10 Figure 2-9’s algorithm in flowchart form
18An Introduction to Programming with C++, Seventh Edition
Step 2−Planning the Algorithm (cont’d.)
• A problem can have more than one solution
Step 2−Planning the Algorithm (cont’d.)
Figure 2-11 A different solution to the
Treyson Mobley problem (pseudocode)
19An Introduction to Programming with C++, Seventh Edition
• 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
Treyson Mobley problem (flowchart)
20An Introduction to Programming with C++, Seventh Edition
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++, Seventh Edition
Step 3−Desk-Checking the Algorithm
(cont’d.)
Figure 2-12 Manual tip calculation for the first desk-check
22An Introduction to Programming with C++, Seventh Edition
Step 3−Desk-Checking the Algorithm
(cont’d.)
Figure 2-13 Treyson Mobley solution and
partially completed desk-check table
23An Introduction to Programming with C++, Seventh Edition
Step 3−Desk-Checking the Algorithm
(cont’d.)
Figure 2-14 Input values entered in the desk-check table
Figure 2-15 Processing item’s value
entered in the desk-check table
Figure 2-16 Output value entered in the desk-check table
24An Introduction to Programming with C++, Seventh Edition
Step 3−Desk-Checking the Algorithm
(cont’d.)
Figure 2-17 Manual tip calculation for
the second desk-check
25An Introduction to Programming with C++, Seventh Edition
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++, Seventh Edition
Step 3−Desk-Checking the Algorithm
(cont’d.)
• 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++, Seventh Edition
The Gas Mileage Problem
Figure 2-21 Problem specification for the gas mileage problem
28An Introduction to Programming with C++, Seventh Edition
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++, Seventh Edition
• 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++, Seventh Edition
• 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++, Seventh Edition
• 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++, Seventh Edition
• Aiden Nelinski is paid every Friday and will receive
either a 2.0% or 2.5% raise next week
• He wants a program that calculates and displays the
amount of his new weekly pay
Lab 2-1: Stop and Analyze
Figure 2-26 IPO chart for Lab 2-1
33An Introduction to Programming with C++, Seventh Edition
• Create an algorithm for the manager of the Lakeview
Hotel
Lab 2-2: Plan and Create
Figure 2-30 Completed IPO chart for Lab 2-2
34An Introduction to Programming with C++, Seventh Edition
• Each guest of the Lakeview Hotel pays an
entertainment tax, which is a percentage of the room
charge only
• Modify the IPO chart in Figure 2-30
• Desk-check the algorithm twice using the given values
Lab 2-3: Modify
35An Introduction to Programming with C++, Seventh Edition
• An algorithm is given to calculate and display an annual
property tax
• Desk-check the algorithm three times using the given
values
Lab 2-4: Desk-Check
Figure 2-36 IPO chart for Lab 2-4
36An Introduction to Programming with C++, Seventh Edition
• An algorithm is given to calculate and display the
average of three numbers but is incorrect
• Find and correct the errors in the algorithm
Lab 2-5: Debug
Figure 2-37 IPO chart for Lab 2-5
Figure 2-42 Corrected algorithm for Lab 2-5
37An Introduction to Programming with C++, Seventh Edition

More Related Content

What's hot

Make learning a fun the use of games in esl classroom
Make learning a fun the use of games in esl classroomMake learning a fun the use of games in esl classroom
Make learning a fun the use of games in esl classroom
Farjana Ferdous
 
Dom(document object model)
Dom(document object model)Dom(document object model)
Dom(document object model)
Partnered Health
 
FP304 DATABASE SYSTEM FINAL PAPER
FP304    DATABASE SYSTEM FINAL PAPERFP304    DATABASE SYSTEM FINAL PAPER
FP304 DATABASE SYSTEM FINAL PAPER
Syahriha Ruslan
 
Pre, while and post listening skills and activities
Pre, while and post listening skills and activitiesPre, while and post listening skills and activities
Pre, while and post listening skills and activities
Alexander Benito
 
Er & eer to relational mapping
Er & eer to relational mappingEr & eer to relational mapping
Er & eer to relational mappingsaurabhshertukde
 
Dbms lab questions
Dbms lab questionsDbms lab questions
Dbms lab questions
Parthipan Parthi
 
database Normalization
database Normalizationdatabase Normalization
database Normalization
Harsiddhi Thakkar
 
Sql subquery
Sql  subquerySql  subquery
Sql subquery
Raveena Thakur
 
Data structures chapter 1
Data structures chapter  1Data structures chapter  1
Data structures chapter 1
priyavanimurugarajan
 
Unit 3 - Function & Grouping,Joins and Set Operations in ORACLE
Unit 3 - Function & Grouping,Joins and Set Operations in ORACLEUnit 3 - Function & Grouping,Joins and Set Operations in ORACLE
Unit 3 - Function & Grouping,Joins and Set Operations in ORACLE
DrkhanchanaR
 
Teaching English skills
Teaching English skills Teaching English skills
Teaching English skills
Irina K
 
Introduction to visual basic programming
Introduction to visual basic programmingIntroduction to visual basic programming
Introduction to visual basic programmingRoger Argarin
 
Unit I Database concepts - RDBMS & ORACLE
Unit I  Database concepts - RDBMS & ORACLEUnit I  Database concepts - RDBMS & ORACLE
Unit I Database concepts - RDBMS & ORACLE
DrkhanchanaR
 
Laporan praktikum modul 2 (membuat table, primary key,foreign key menggunakan...
Laporan praktikum modul 2 (membuat table, primary key,foreign key menggunakan...Laporan praktikum modul 2 (membuat table, primary key,foreign key menggunakan...
Laporan praktikum modul 2 (membuat table, primary key,foreign key menggunakan...
Devi Apriansyah
 
ADO Controls - Database Usage from Exploring MS Visual Basic 6.0 Book
ADO Controls - Database Usage from Exploring MS Visual Basic 6.0 BookADO Controls - Database Usage from Exploring MS Visual Basic 6.0 Book
ADO Controls - Database Usage from Exploring MS Visual Basic 6.0 Book
Muralidharan Radhakrishnan
 

What's hot (20)

Make learning a fun the use of games in esl classroom
Make learning a fun the use of games in esl classroomMake learning a fun the use of games in esl classroom
Make learning a fun the use of games in esl classroom
 
Dom(document object model)
Dom(document object model)Dom(document object model)
Dom(document object model)
 
Point task based-learning
Point task based-learningPoint task based-learning
Point task based-learning
 
FP304 DATABASE SYSTEM FINAL PAPER
FP304    DATABASE SYSTEM FINAL PAPERFP304    DATABASE SYSTEM FINAL PAPER
FP304 DATABASE SYSTEM FINAL PAPER
 
Pre, while and post listening skills and activities
Pre, while and post listening skills and activitiesPre, while and post listening skills and activities
Pre, while and post listening skills and activities
 
Er & eer to relational mapping
Er & eer to relational mappingEr & eer to relational mapping
Er & eer to relational mapping
 
Asp.net controls
Asp.net controlsAsp.net controls
Asp.net controls
 
Dbms lab questions
Dbms lab questionsDbms lab questions
Dbms lab questions
 
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
Views, Triggers, Functions, Stored Procedures,  Indexing and JoinsViews, Triggers, Functions, Stored Procedures,  Indexing and Joins
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
 
database Normalization
database Normalizationdatabase Normalization
database Normalization
 
Sql subquery
Sql  subquerySql  subquery
Sql subquery
 
Data structures chapter 1
Data structures chapter  1Data structures chapter  1
Data structures chapter 1
 
Unit 3 - Function & Grouping,Joins and Set Operations in ORACLE
Unit 3 - Function & Grouping,Joins and Set Operations in ORACLEUnit 3 - Function & Grouping,Joins and Set Operations in ORACLE
Unit 3 - Function & Grouping,Joins and Set Operations in ORACLE
 
Teaching English skills
Teaching English skills Teaching English skills
Teaching English skills
 
Introduction to visual basic programming
Introduction to visual basic programmingIntroduction to visual basic programming
Introduction to visual basic programming
 
Unit I Database concepts - RDBMS & ORACLE
Unit I  Database concepts - RDBMS & ORACLEUnit I  Database concepts - RDBMS & ORACLE
Unit I Database concepts - RDBMS & ORACLE
 
Lesson plan reading 16072013
Lesson plan reading 16072013Lesson plan reading 16072013
Lesson plan reading 16072013
 
PLSQL Cursors
PLSQL CursorsPLSQL Cursors
PLSQL Cursors
 
Laporan praktikum modul 2 (membuat table, primary key,foreign key menggunakan...
Laporan praktikum modul 2 (membuat table, primary key,foreign key menggunakan...Laporan praktikum modul 2 (membuat table, primary key,foreign key menggunakan...
Laporan praktikum modul 2 (membuat table, primary key,foreign key menggunakan...
 
ADO Controls - Database Usage from Exploring MS Visual Basic 6.0 Book
ADO Controls - Database Usage from Exploring MS Visual Basic 6.0 BookADO Controls - Database Usage from Exploring MS Visual Basic 6.0 Book
ADO Controls - Database Usage from Exploring MS Visual Basic 6.0 Book
 

Viewers also liked

Unit 2. Elements of C
Unit 2. Elements of CUnit 2. Elements of C
Unit 2. Elements of C
Ashim Lamichhane
 
Chapter 2 - Beginning the Problem-Solving Process
Chapter 2 - Beginning the Problem-Solving ProcessChapter 2 - Beginning the Problem-Solving Process
Chapter 2 - Beginning the Problem-Solving Process
mshellman
 
Problem solving using Computer
Problem solving using ComputerProblem solving using Computer
Problem solving using Computer
David Livingston J
 
Introduction to problem solving in C
Introduction to problem solving in CIntroduction to problem solving in C
Introduction to problem solving in C
Diwakar Pratap Singh 'Deva'
 
Unit 1. Problem Solving with Computer
Unit 1. Problem Solving with Computer   Unit 1. Problem Solving with Computer
Unit 1. Problem Solving with Computer
Ashim Lamichhane
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
Deva Singh
 

Viewers also liked (7)

Ch02
Ch02Ch02
Ch02
 
Unit 2. Elements of C
Unit 2. Elements of CUnit 2. Elements of C
Unit 2. Elements of C
 
Chapter 2 - Beginning the Problem-Solving Process
Chapter 2 - Beginning the Problem-Solving ProcessChapter 2 - Beginning the Problem-Solving Process
Chapter 2 - Beginning the Problem-Solving Process
 
Problem solving using Computer
Problem solving using ComputerProblem solving using Computer
Problem solving using Computer
 
Introduction to problem solving in C
Introduction to problem solving in CIntroduction to problem solving in C
Introduction to problem solving in C
 
Unit 1. Problem Solving with Computer
Unit 1. Problem Solving with Computer   Unit 1. Problem Solving with Computer
Unit 1. Problem Solving with Computer
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
 

Similar to Chapter 02 - Problem Solving

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
MLG College of Learning, Inc
 
Lesson 4.1 completing the problem solving process
Lesson 4.1 completing the problem solving processLesson 4.1 completing the problem solving process
Lesson 4.1 completing the problem solving process
MLG College of Learning, Inc
 
Computer Programming
Computer ProgrammingComputer Programming
Computer Programming
Burhan Fakhar
 
Flowchart and algorithm
Flowchart and algorithmFlowchart and algorithm
Flowchart and algorithm
DHANIK VIKRANT
 
Basic of c++ programming
Basic of c++ programmingBasic of c++ programming
Basic of c++ programming
Talha Mughal
 
Chapter0002222programming language2.pptx
Chapter0002222programming language2.pptxChapter0002222programming language2.pptx
Chapter0002222programming language2.pptx
stephen972973
 
9781285852744 ppt ch02
9781285852744 ppt ch029781285852744 ppt ch02
9781285852744 ppt ch02
Terry Yoast
 
UoN-Lec_12_Control_Structure.pdf
UoN-Lec_12_Control_Structure.pdfUoN-Lec_12_Control_Structure.pdf
UoN-Lec_12_Control_Structure.pdf
madihamaqbool6
 
Visual programming
Visual programmingVisual programming
Visual programming
Dr. C.V. Suresh Babu
 
Chapter03_PPT.ppt
Chapter03_PPT.pptChapter03_PPT.ppt
Chapter03_PPT.ppt
DrRajeswari5
 
Algorithm.pdf
Algorithm.pdfAlgorithm.pdf
Algorithm.pdf
MIT,Imphal
 
PPT slide_chapter 02 Basic element of C++.ppt
PPT slide_chapter 02 Basic element of C++.pptPPT slide_chapter 02 Basic element of C++.ppt
PPT slide_chapter 02 Basic element of C++.ppt
masadjie
 
C++.ppt
C++.pptC++.ppt
C++.ppt
shweta210
 
Cocomomodel
CocomomodelCocomomodel
COCOMO Model
COCOMO ModelCOCOMO Model
COCOMO Model
Dev Kishan Bairwa
 
8.2 approach in problem solving (9 hour)
8.2 approach in problem solving (9 hour)8.2 approach in problem solving (9 hour)
8.2 approach in problem solving (9 hour)Fiqry Suryansyah
 
COMP 122 Entire Course NEW
COMP 122 Entire Course NEWCOMP 122 Entire Course NEW
COMP 122 Entire Course NEW
shyamuopeight
 
visualbasicprograming
visualbasicprogramingvisualbasicprograming
visualbasicprogramingdhi her
 

Similar to Chapter 02 - Problem Solving (20)

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
 
Lesson 4.1 completing the problem solving process
Lesson 4.1 completing the problem solving processLesson 4.1 completing the problem solving process
Lesson 4.1 completing the problem solving process
 
Cs 1114 - lecture-2
Cs 1114 - lecture-2Cs 1114 - lecture-2
Cs 1114 - lecture-2
 
Computer Programming
Computer ProgrammingComputer Programming
Computer Programming
 
Flowchart and algorithm
Flowchart and algorithmFlowchart and algorithm
Flowchart and algorithm
 
Basic of c++ programming
Basic of c++ programmingBasic of c++ programming
Basic of c++ programming
 
Chapter0002222programming language2.pptx
Chapter0002222programming language2.pptxChapter0002222programming language2.pptx
Chapter0002222programming language2.pptx
 
9781285852744 ppt ch02
9781285852744 ppt ch029781285852744 ppt ch02
9781285852744 ppt ch02
 
UoN-Lec_12_Control_Structure.pdf
UoN-Lec_12_Control_Structure.pdfUoN-Lec_12_Control_Structure.pdf
UoN-Lec_12_Control_Structure.pdf
 
Visual programming
Visual programmingVisual programming
Visual programming
 
Chapter03_PPT.ppt
Chapter03_PPT.pptChapter03_PPT.ppt
Chapter03_PPT.ppt
 
Algorithm.pdf
Algorithm.pdfAlgorithm.pdf
Algorithm.pdf
 
PPT slide_chapter 02 Basic element of C++.ppt
PPT slide_chapter 02 Basic element of C++.pptPPT slide_chapter 02 Basic element of C++.ppt
PPT slide_chapter 02 Basic element of C++.ppt
 
C++.ppt
C++.pptC++.ppt
C++.ppt
 
Cocomomodel
CocomomodelCocomomodel
Cocomomodel
 
Cocomo model
Cocomo modelCocomo model
Cocomo model
 
COCOMO Model
COCOMO ModelCOCOMO Model
COCOMO Model
 
8.2 approach in problem solving (9 hour)
8.2 approach in problem solving (9 hour)8.2 approach in problem solving (9 hour)
8.2 approach in problem solving (9 hour)
 
COMP 122 Entire Course NEW
COMP 122 Entire Course NEWCOMP 122 Entire Course NEW
COMP 122 Entire Course NEW
 
visualbasicprograming
visualbasicprogramingvisualbasicprograming
visualbasicprograming
 

Recently uploaded

Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 

Recently uploaded (20)

Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 

Chapter 02 - Problem Solving

  • 1. Introduction to Programming in C++ Seventh Edition Chapter 2: Beginning the Problem-Solving Process
  • 2. • 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++, Seventh Edition
  • 3. • 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++, Seventh Edition
  • 4. • 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++, Seventh Edition
  • 5. 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++, Seventh Edition
  • 6. Solving Everyday Problems (cont’d.) Figure 2-2 Modified algorithm for the bill paying problem 6An Introduction to Programming with C++, Seventh Edition
  • 7. • 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++, Seventh Edition
  • 8. 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++, Seventh Edition
  • 9. • 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++, Seventh Edition
  • 10. Step 1−Analyzing the Problem (cont’d.) Figure 2-4 Problem specification for Treyson Mobley 10An Introduction to Programming with C++, Seventh Edition
  • 11. • 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++, Seventh Edition
  • 12. • 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++, Seventh Edition
  • 13. • 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++, Seventh Edition
  • 14. • 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++, Seventh Edition
  • 15. • 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++, Seventh Edition
  • 16. Step 2−Planning the Algorithm (cont’d.) Figure 2-9 Problem specification and IPO chart for the Treyson Mobley problem 16An Introduction to Programming with C++, Seventh Edition
  • 17. • 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++, Seventh Edition
  • 18. Figure 2-10 Figure 2-9’s algorithm in flowchart form 18An Introduction to Programming with C++, Seventh Edition Step 2−Planning the Algorithm (cont’d.)
  • 19. • A problem can have more than one solution Step 2−Planning the Algorithm (cont’d.) Figure 2-11 A different solution to the Treyson Mobley problem (pseudocode) 19An Introduction to Programming with C++, Seventh Edition
  • 20. • 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 Treyson Mobley problem (flowchart) 20An Introduction to Programming with C++, Seventh Edition
  • 21. 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++, Seventh Edition
  • 22. Step 3−Desk-Checking the Algorithm (cont’d.) Figure 2-12 Manual tip calculation for the first desk-check 22An Introduction to Programming with C++, Seventh Edition
  • 23. Step 3−Desk-Checking the Algorithm (cont’d.) Figure 2-13 Treyson Mobley solution and partially completed desk-check table 23An Introduction to Programming with C++, Seventh Edition
  • 24. Step 3−Desk-Checking the Algorithm (cont’d.) Figure 2-14 Input values entered in the desk-check table Figure 2-15 Processing item’s value entered in the desk-check table Figure 2-16 Output value entered in the desk-check table 24An Introduction to Programming with C++, Seventh Edition
  • 25. Step 3−Desk-Checking the Algorithm (cont’d.) Figure 2-17 Manual tip calculation for the second desk-check 25An Introduction to Programming with C++, Seventh Edition
  • 26. 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++, Seventh Edition Step 3−Desk-Checking the Algorithm (cont’d.)
  • 27. • 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++, Seventh Edition
  • 28. The Gas Mileage Problem Figure 2-21 Problem specification for the gas mileage problem 28An Introduction to Programming with C++, Seventh Edition
  • 29. 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++, Seventh Edition
  • 30. • 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++, Seventh Edition
  • 31. • 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++, Seventh Edition
  • 32. • 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++, Seventh Edition
  • 33. • Aiden Nelinski is paid every Friday and will receive either a 2.0% or 2.5% raise next week • He wants a program that calculates and displays the amount of his new weekly pay Lab 2-1: Stop and Analyze Figure 2-26 IPO chart for Lab 2-1 33An Introduction to Programming with C++, Seventh Edition
  • 34. • Create an algorithm for the manager of the Lakeview Hotel Lab 2-2: Plan and Create Figure 2-30 Completed IPO chart for Lab 2-2 34An Introduction to Programming with C++, Seventh Edition
  • 35. • Each guest of the Lakeview Hotel pays an entertainment tax, which is a percentage of the room charge only • Modify the IPO chart in Figure 2-30 • Desk-check the algorithm twice using the given values Lab 2-3: Modify 35An Introduction to Programming with C++, Seventh Edition
  • 36. • An algorithm is given to calculate and display an annual property tax • Desk-check the algorithm three times using the given values Lab 2-4: Desk-Check Figure 2-36 IPO chart for Lab 2-4 36An Introduction to Programming with C++, Seventh Edition
  • 37. • An algorithm is given to calculate and display the average of three numbers but is incorrect • Find and correct the errors in the algorithm Lab 2-5: Debug Figure 2-37 IPO chart for Lab 2-5 Figure 2-42 Corrected algorithm for Lab 2-5 37An Introduction to Programming with C++, Seventh Edition