0% found this document useful (0 votes)
98 views13 pages

Problem Definition and Analysis

The document provides details about a laboratory activity introducing algorithm design and representation using C++ programming. It discusses the steps in problem definition, design using algorithms and flowcharts, implementation, and testing. It then provides two sample problems - calculating an employee's new monthly pay with a raise, and calculating a student's quiz average and whether they passed or failed. For each problem it lists the inputs, outputs, and provides the narrative and pseudocode algorithms as well as flowcharts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
98 views13 pages

Problem Definition and Analysis

The document provides details about a laboratory activity introducing algorithm design and representation using C++ programming. It discusses the steps in problem definition, design using algorithms and flowcharts, implementation, and testing. It then provides two sample problems - calculating an employee's new monthly pay with a raise, and calculating a student's quiz average and whether they passed or failed. For each problem it lists the inputs, outputs, and provides the narrative and pseudocode algorithms as well as flowcharts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Course: CPE 102A-EE21S1 - Computer Experiment No.

:
Programming
Name: Bencalo, Mark Emmanuel L. Section: EE21S1
Date Performed: October 27, 2021
Date Submitted: October 27, 2021
Instructor: ENG'R. JULIE ANN B. SUSA

LABORATORY ACTIVITY NO.1

ALGORITHM DESIGN AND REPRESENTATION

1. Objective(s):

The activity aims to introduce the significance of algorithm and flowchart in creating a program using C++
programming language base on the requirement.

2. Intended Learning Outcomes (ILOs):

The students shall be able to:

1. Familiarize on different analytical tools in software development


2. Understand and apply the use of algorithm and flowcharting in solving mathematical problems

3. Discussion:

In program development, there are steps/procedures that have to follow. Figure 1. shows the
program development life cycle.

Problem Definition
and Analysis

Design

Implementation

Testing

Figure 1. Program Development Life Cycle


Problem Definition and Analysis

The first step in solving a problem is to define and analyze the problem. The purpose of
defining and analyzing a problem is to determine the goal of solving a problem and the items that are
needed to achieve that goal. Programmers refer to the goal as the output, and they refer to the items
needed to achieve the goal as the input. In defining and analyzing a problem, always search first for the
output, and then for the input. Some programmers use an input, process and output (IPO) chart to organize and
summarize the results of problem definition and analysis. Table 1 shows how to make use of IPO. The details
discussion of the chart is in the second step of problem-solving process.

Input Processing Output

1. Processing items:

2. Algorithm:

a. Narrative form:

b. Pseudocode

Table 1. IPO Chart

Design

Algorithm

The second step in the problem-solving process is to plan a design using analytical tools such
as algorithm and flowchart. Algorithm has two different forms, a narrative form or short English
statements and statements closer to the instructions in the program which is called pseudocode. These two
forms of algorithm have the same output which is the steps/procedures in developing the programof the
given problem. Record the algorithm in the processing column of the IPO chart. Most algorithms begin with
an instruction that enters the input items into the computer. The Input items are the items listed in the
Input column of the IPO chart. A processing item represents an intermediate value that the algorithm uses
when processing the input into the output. Most algorithms end an instruction to display, print, or store the
output items listed in the Output column of the IPO chart.
A programmer reviews an algorithm by desk-checking, or hand-tracing, it in other words, by
completing each step in the algorithm manually. You desk-check an algorithm to verify that it is not
missing any steps, and that the existing steps are correct and in the proper order. Before you begin the
desk-check, first choose a set of sample data for the input value, which you then use to manually
compute the expected output values. If every step has no errors, a programmer now can construct a
flowchart.

Flowchart

Flowchart is a graphical representation of a program, derived from the algorithm. It uses


standardized symbols to show the steps that must be followed to accomplish the program’s goal.

Terminal Processing box Input/output box Initialization Box

Decision On-page Off - page connector Arrow


heads

Figure 2.Basic Flowchart Symbol


Implementation

Only after the programmer is satisfied that the flowchart is correct does he or she then move
on to the fourth step in the problem-solving process which is implementation. Implementation is a step
where the programming is converting the designs into codes. A code is a language that the computer
can understand.

After completing the codes, the programmer then desk-checks the program to make sure that
the algorithm and flowchart were translated correctly, then final process in the problem-solving process can
be done.

Testing

The final step in the problem-solving process is to test if the codes have no errors using the
component of a programming language such as compiler or assembler that detects errors. This is
usually done by entering, into the computer, the C++ instructions listed in your algorithm. Other
instructions required by the C++ compiler have to be entered as well. After entering the appropriate
instructions, you then run (execute) the program. (More details will be discussed in Activity no. 2.)

4. Resources:

DevC++

5. Procedure and Output

EXERCISE No. 1 (Simple Problem)

Sarah Cruz has been working for COMPUTER Z Company for four years. Last year, Sarah received a 5%
raise, which brought her current monthly pay to 25,000.00 pesos. Sarah is scheduled to receive a 4% raise
next month. She wants to write a program that will display, on the computer screen, the amount of her new
monthly pay.

1. What is required in the problem given?

-The required problem is to write a program/ display her new 4% raise that is said to be added
next month.

2. What is/are input item/s?

-The input items are Sarah’s 25,000 pesos monthly pay and the 4% raise that she will be
receiving next month.
3.What is/are the processing item/s?

-The processing items are new income = previous income + (previous income x pay raise/100).

4.What is/are the output/s of the problem?

-The output will be the new income that Sarah is expected to receive next month.

ALGORITHM

NARRATIVE PSEUDOCODE
-Start the programming
language. To calculate the new Step 1: Start the
income, state the previous programming language.
outcome and the state the Step 2: Enter the 25,00php
percentage pay rises. Compute (previous income).
the new income by Previous Step 3: Enter the percentage
Income (Previous Income x pay pay raise.
raise/100). Display the New Step 4: Compute new
Income and end the income = previous income
programming language. (previous income x pay
raises/100).
Step 5: Display the New
income.
Step 6: End.
FLOWCHART

Start

Enter the
25,00php (previous
income)

Enter the 4% (pay


raise)

Compute new income =


previous income
(previous income x pay
raises/100)

Print the
New
income

End
EXERCISE No. 2 (Problem Involving Condition)
A student took four quizzes in a term and would like to compute their average. He also would like to know if the average has
a passing mark. Note that grade lower than 75% is failed.

1. What is required in the problem given?

Step 1: The required is the average of the four quizzes and to know if it passed or failed.

2. What is/are input item/s?

Step 2: The score of the four students on their quizzes and the total number of quizzes that
they have taken.

3. What is/are the processing item/s?

Step 3: The processing items are the total score, total number of items and is divided to 100.

4. What is/are the output/s of the problem?

Step 4: The outputs are the Average of the four marks and to identify if the grade is lower that
75% or higher.
ALGORITHM

NARRATIVE PSEUDOCODE
-Start the programming language Step 1: Start the programming
and state the 4 quizzes scores. Add language.
up the total marks. Calculate the Step 2: Enter the 4 quizzes scores.
average by dividing the total scores Step 3: Enter the total sum of quizzes
by four. Calculate the percentage of Step 4: Compute the average by Total
score by Total score divided by Total scores of quizzes divided by 4.
number of items times 100. If the Step 5: Compute percentage by (Total
percentage is less than 75% then score divided by total number of
display failed, Else If the student items) x 100.
percentage is greater than 75% then Step 6: IF percentage is <75%.
display passed. End the Step 7: Display Failed.
programming language. Step 8: Else, IF Percentage is > 75%.
Step 9: Display Passed.
Step 10: End.
FLOWCHART

Start

Enter the total sum


of quizzes

Compute Average = Total


score of quizzes / 4

Compute Percentage =
(Total score / Total
number of items) / 100

IF Percentage is
< 75% Print
Failed, IF P is >
75% Print
Passed.

End
EXERCISE No. 3 (Problem Involving Iteration)

Jonathan was given an assignment in his programming course that requires


creating an algorithm and flowchart of ten input numbers then displaying its sum.
1. What is required in the problem given?
-The required in the problem is the sum of a variable and its loop in taking the 10
input numbers.
2. What is/are input item/s?
-Since the problem requires summation of 10 numbers, the requirement is to have 10
input numbers.
3. What is/are the processing item/s?
- New inputs are to be added to the sum variable.
4. What is/are the output/s of the problem?
-The output will be the sum of 10 numbers.

ALGORITHM

NARRATIVE PSEUDOCODE
Step 1: Start the programming
-Start the programming language.
language, and state the 10 Step 2: Enter the 10 numbers.
numbers that are separated, read Step 3: Read reply to numbers
the reply to console and loop. If then Loop the numbers.
the reply says blank, break the Step 4: IF the reply is blank,
loop. Get the number from the break, get the number from
reply and add 1 to a count. Get reply.
the summation of the numbers Step 5: Add 1 count and total
and repeat, write “the total is:” the numbers.
then End The programming Step 6: Repeat.
language. Step 7: Write “the total is:”
Step 8: End.
FLOWCHART

Start

Enter the 10
numbers

Read reply to console,


then, loop.

IF the reply is blank,


break, get the number
from reply.

Add 1 count and total the


numbers. Repeat.

Write “the total is:”

End
6. Conclusion:

-I have realized how satisfying the computer language are, it gives me a huge advantage and makes things
easier. The problems were really confusing at first, but it helps me improve my analyzing skills to the fact that
I can identify what is the proper formula to be used. Each problem was interesting, and it help me develop my
problem-solving skills, it was hard identifying the process but at the end of the activity I managed to have the
grasp the given task. Furthermore, the activity was fun and continued to aspire me into computer programing.

You might also like