Presentation is loading. Please wait.

Presentation is loading. Please wait.

PROBLEM SOLVING. What is a Problem? A problem is a situation that needs to be resolved.

Similar presentations


Presentation on theme: "PROBLEM SOLVING. What is a Problem? A problem is a situation that needs to be resolved."— Presentation transcript:

1 PROBLEM SOLVING

2 What is a Problem? A problem is a situation that needs to be resolved

3 How do we resolve a problem?  We find Solutions solution ‘ A solution is a means of solving a problem or dealing with a difficult situation’. best  We choose the best solution!

4 CHARACTERISTICS OF A GOOD SOLUTION  UNAMBIGUOUS (CLEAR/PRECISE)  LOGICAL  COMPLETE (Finite number of steps)  ACCURATE

5 ACTIVITY  Write instructions for a student to get up from her seat, leave the back of the class and open the door.  Persons work in pairs. One person instruct the other person to draw a shape without telling them what the shape is. The other person then shows her peer the shape she has drawn to determine if the instructions were clear.  Give instructions for your favourite recipe

6 Problem Solving- Computers  Computers are designed to solve problems speedily and accurately  Computers cannot think or reason on its own. Basically, what is input is exactly what is output (GIGO)  Computers simply follow instructions to produce specified results

7 Computers  Computers are NOT intelligent.  It cannot analyze a problem and come up with a solution.  A programmer comes up with the solution.  Once we have written a solution for the computer, it can repeat the instructions quickly and consistently.  The computer frees people from repetitive and boring tasks.

8 Steps in Problem Solving  Define the problem  Propose and analyze solutions  Determine the most efficient solution  Develop an algorithm  Test and validate the solution

9 Problem Solving The following documents are produced in the problem solving and programming stages: 1. Problem definition- understand and state what the problem. Produce a statement. 2. Defining Diagram- breaks down the problem into Input, Process and Output 3. Algorithm - steps to solve the problem 4. Pseudocode- ‘fake’ code. It is taken produced using the algorithm OR Flowchart- diagrammatic representation of the algorithm 5. Program 6. Test data

10 Creating an I-P-O chart  Also known as a defining diagram  Identifies the inputs, processing steps and the outputs related to the problem INPUTPROCESSINGOUTPUT What is givenAll the instructions that must be executed to transform the input into the expected results (output) The expected results Remember the main stages of data processing in the computer are INPUT- PROCESS- OUTPUT

11 Example of an I-P-O diagram for Bread INPUTPROCESSOUTPUT Flour Water Yeast Salt Margarine 1.Prepare yeast & mix ingredients. 2.Form dough into ball and let rise 3.Form dough into loaf and place in pans 4.Bake in oven at 350 degrees F until loaf is golden brown bread

12 ACTIVITY Produce a Defining diagram (IPO chart) for the following problems: 1. The computer has to find the sum of two numbers and display the result. 2. The computer receives two numbers, finds the difference between the numbers and prints the answer. 3. The computer receives the length and width of a rectangle, calculates the area and the perimeter and prints the results.

13 ACTIVITY 2 Produce a Defining diagram (IPO chart) for the following problems: 1. The computer receives the name of a student and three marks, calculates the average and prints the name of the student and the average mark. 2. The computer receives the name of an item and the cost of the item; calculates the new price at a Value Added Tax of 15%. The name of the item, the cost of the item and the cost of the item after vat is displayed on the screen.

14 Variables How data is stored  Programs use variables and constants as containers for storing data in RAM. Each of these containers must be provided with: i. What the container will store. It can store either a fixed value which is referred to as a constant (e.g. Tax rate) or a value that will change (variable- value entered by the user). ii. Name- called an identifier iii. Data type

15 Naming a variable  The variable name should be descriptive and meaningful. For example, if I wanted to name a variable for name of student, I would use the variable, STUDENT_NAME instead of something meaningless like N.  The variable must start with a letter. It cannot begin with a number or any other character.  There should be no spaces in a variable name. For example, I can say STUDENT_NAME or studentname but NOT STUDENT NAME.  A variable name should not be too lengthy.  A variable can be alphanumeric (e.g. Num1)  A variable can be one letter (e.g. N, x)

16 Activity- Variables A. Identify the correct variable names: 1. PRICE 2. %LOCATION 3. address 4. 789contact 5. Student_ID 6. answer1 7. x 8. Itemcost

17 Activity-Defining diagram  Produce a defining diagram using the following information: 1. Write an algorithm to determine and display the average age and height of three persons. 2. Write an algorithm to read a month in the year and print “Free gift voucher for Chuckee Cheese” if the child’s date of birth is in the month of June.

18 ALGORITHM  An algorithm is a set of instructions that if followed in a particular sequence will lead to a solution to the problem. All algorithms must be: 1. Have a set number of steps 2. Precise 3. Unambiguous (not confusing) 4. Eventually terminate/end Before the algorithm is formulated an IPO or defining diagram is produced to identify the Input, process and outputs

19 Words in Programming- ALGORITHM  INPUT- GET, INPUT, READ  OUTPUT- PRINT, DISPLAY, OUTPUT  PROCESS- DETERMINE, CALCULATE, COMPUTE, COMPARE

20 For calculations the following operators are used: Arithmetic OperatorArithmetic ExpressionMeaning of expression + (Addition) Val= Num1 + Num2 Add the values Num1 and Num2 and place the resulting value in the variable Val. - (Subtraction)Val = Num1 - Num2 Subtract the value stored in Num2 from the value stored in Num1 and place the resulting value in the variable Val. * (Multiplication)Val = Num1 * Num2 Multiply the values in Num1 and Num2 and place the resulting value in the variable Val. / (Division)Val = Num1/ Num2 ORDivide Num1 by the divisor Num2 and place the result in Val

21 Problem Solving Example: INPUTPROCESSOUTPUT PRICE1, PRICE2, PRICE3 1. Get PRICE1, PRICE2, PRICE3AVERAGE_PRICE 2. Calculate the average price by finding the sum of the three prices and dividing the sum by 3 3. Output the AVERAGE_PRICE Q1. Write pseudocode to input three prices, compute their average and output the result with a message.

22 ALGORITHM 1. Read three prices: Price1, Price2 and Price3 2. Calculate the average price by finding the sum of the three prices and dividing the sum by 3. 3. Print the average price

23 INDEPENDENT PRACTICE  Produce algorithms for the questions in slide 13 (Activity 2)

24  http://www.bbc.co.uk/guides/z23q7ty http://www.bbc.co.uk/guides/z23q7ty  https://www.khanacademy.org/computing/computer- programming/programming/variables/p/challenge-funky-frog https://www.khanacademy.org/computing/computer- programming/programming/variables/p/challenge-funky-frog

25


Download ppt "PROBLEM SOLVING. What is a Problem? A problem is a situation that needs to be resolved."

Similar presentations


Ads by Google