Creating Solution
Creating Solution
Creating Solution
SOLUTIONS TO PROBLEMS
How To Create a Computer Solution to a
Problem
ANALYZE THE
PROBLEM
PLAN THE
ALGORITHM
DESK CHECK
STEP 1 – ANALYZE THE
PROBLEM
STEP 1 – ANALYZE THE
PROBLEM
You cannot solve a problem unless you understand it, and you
cannot understand a problem unless you analyze it—in other
words, unless you identify its important components. Th e two
most important components of any problem are the problem’s
output and its input. The output is the goal of solving the
problem, and the input is the item or items needed to achieve
the goal. When analyzing a problem, you always search first for
the output and then for the input.
EXAMPLE INPUT PROCESS OUTPUT
TWO 1 Sum = 1 + 1 2
NUMBERS 1
INPUT PROCESS OUTPUT
Average = S / T
Step 1: Start
Read/Enter num1
Step 2: Declare variables
and num2
num1, num2 and sum.
Step 3: Read values for num1
and num2.
Step 4: Add num1 and num2
Sum = num1 + num2
and assign the result to
variable sum.
sum=num1+num2
Step 5: Display sum
Step 6: Stop Display sum
END
START
A
Addison O’Reilly wants
a program that calculates Declare variables cost, sale
price, sales tax and sales rate.
and displays the cost… cost = sale price + sales
tax
Step 1: Start
Step 2: Declare variables Read/Enter sales
cost, sale price, sales tax tax rate, sales price
and sales rate. Display COST
Step 3: Calculate sales tax
by multiplying sale price by
sales tax rate.
(sales tax = sale price * sales sales tax = sale price *
tax) sales tax END
Step 4: Calculate cost by
adding sale price plus sales
tax rate. A
(cost = sale price + sales tax)
Step 5: Display Cost
Step 6: End
START
The principal of a local
school wants a program that
displays… Declare variables average,
students and teachers
Step 1: Start
Step 2: Declare variables
Enter/Read values
average, students and for students and
teachers teachers
Step 3: Read values for
students and teachers
Step 4: Calculate average = students
teachers)
average number of
students per teacher
by dividing the number
students by the number Display average
of teachers. (average =
students / teachers)
Step 5: Display average END
Step 6: Stop
Step 1: Start
AGLORITHM Step 2: Declare participants as int
Write an algorithm and draw a
Step 3: Read/Enter participants
flowchart for an alternative selection
structure that displays one of two
Step 4: If participants is equal or greater
different messages, depending on the
than 75 then display “Use Kanton room”
number of seminar participants stored
else if participants is less than 75 then
in an int variable named participants.
display “Use Harris room”
Display the message “Use the Kanton Step 5: Display Output
room” when the number of seminar
Step 6: End
participants is at equal or greater than
75. When less than 75, display the
message “Use the Harris room”.
START
END
DESK CHECK
DESK CHECK First number
1
Second number
1
Sum
2
ADDING TWO NUMBERS
3 5 8
Step 1: Start 100 125 225
Step 2: Declare variables
num1, num2 and sum.
Step 3: Read values for num1
and num2.
Step 4: Add num1 and num2
and assign the result to
variable sum.
sum=num1+num2
Step 5: Display sum
Step 6: Stop
Addison O’Reilly wants
a program that
calculates and displays
Sale price Sales ax rate Sales tax cost
the cost 2300 .05 115 2415
Step 1: Start 1500 .05 75 1575
Step 2: Declare variables 3500 .10 350 3850
cost, sale price, sales tax and
sales rate.
Step 3: Calculate sales tax by
multiplying sale price by
sales tax rate.
(sales tax = sale price * sales
tax)
Step 4: Calculate cost by
adding sale price plus sales
tax rate.
(cost = sale price + sales tax)
Step 5: Display Cost
Step 6: End
The principal of a local
school wants a program
that displays… Students Teachers Average
1200 60 20
Step 1: Start 2500 100 25
Step 2: Declare variables
average, students and
teachers
Step 3: Read values for
students and teachers
Step 4: Calculate average
number of students per
teacher by dividing the
number students by the
number of teachers.
(average = students /
teachers)
Step 5: Display average
Step 6: Stop
Celsius Calculation Output/Fahrenheit
32 (37 / 5) x 9 + 32 89.6