0% found this document useful (0 votes)
34 views

Problem Analysis

The document discusses analyzing problems to develop algorithms. It defines input, processing, and output as the three types of algorithms. It provides examples of identifying the input, processing, and output needed to solve problems like making a phone call, calculating an amount due, and determining a bus driver's bonus. The document explains how to determine what inputs are needed, if calculations are required, and what output is required to analyze a problem and develop an algorithm.

Uploaded by

Teck Ismael
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Problem Analysis

The document discusses analyzing problems to develop algorithms. It defines input, processing, and output as the three types of algorithms. It provides examples of identifying the input, processing, and output needed to solve problems like making a phone call, calculating an amount due, and determining a bus driver's bonus. The document explains how to determine what inputs are needed, if calculations are required, and what output is required to analyze a problem and develop an algorithm.

Uploaded by

Teck Ismael
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 6

Define a problem

 Decompose a problems using an IPO


iidentify the three types of algorithms

 Input
Processing
Storage
Scenario
Imagine your are given the task to make a telephone call
from your home to Peter Dot at 822-0451:

Pick up the receiver


Listen for dial tone
Get dial tone if not present
Dial number when dial tone is present
Listen for a response
Make a decision depending on response
Ask to speak to Peter Dot

The solution to a problem is made up of more


than one operation
Steps
The process of finding out the operations is know as
analyzing the problem

1. Interpreting and understanding


Write a computer program to input the
the problem price of an item and the quantity
2. Determining purchased. The program should
a. Input needed compute and print the amount due.
b. Processing required
c. Output expected 1.Input the price of the item (input & storage)
d. Commands and program 2.Input the quantity purchased (input &
constructs storage)
3.Calculate the amount due (processing &
storage)
4.Print the amount due (output)
Sample
Write a program that calculates and prints the revenue made by a minibus, which
made 20 trips from Belmopan to Belize City. Each passenger paid $4.50. If the
revenue for the day exceeds $500, a bonus of 10% of the revenue is given to the
driver. Compute and print the bonus amount. Input the number of passengers
who travelled on each trip.

1. Input number of passengers for each trip (input & storage)


2. Calculate total number of passengers (processing & storage)
3. Calculate the revenue for the day (processing & storage)
4. Print the revenue (output)
5. Determine if the bonus will be given (processing)
6. If bonus is given, calculate the bonus amount (processing & storage)
7. Print the bonus amount ( output)
How to…
Determine if input is needed:
Look for keywords or phrases: read, input, enter, prompt
Check if processing or output depend on input

Know if calculations are required:


Look for words like calculate or compute
Check for the need to carry out mathematical operations
Identify the need for sum, average or percentage

Identify the need to repeat some instructions:


Check for input of several items for same attribute
Look for keywords: dummy value, terminated by, repeat until, continue
Check for validation of the input values
Know what output is required:
Check for keywords: print, output, display, list, suitable label,
appropriately labeled, prompt the user or caption
Analysis
9. In a regional exam 20 students got scores for the mathematics paper.
Input the scores for all 20 students. Calculate and print the average
score and also the lowest and highest scores achieved.
 Initialize a running total to zero (storage)
 Initialize a low value to 100 (storage)
 Initialize a high value to 0 (storage)
 Input score per student (input & storage)
 For each student
 Update running total (processing & storage)
Repetition
(Loop)

 Check if score is lower (processing)


 If lower update low value (processing & storage)
 Check if score is higher (processing)
 If higher update high value (processing & storage)
 Calculate average score (processing & storage)
 Print average score (output)
 Print high value (output)
 Print low value (output)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy