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

Slides:



Advertisements
Similar presentations
CS101: Introduction to Computer programming
Advertisements

Andrew C. Samuels, Information Technology Specialist Trainer c/o Ministry of Education Mona High School, Kingston, Jamaica 1 Problem Solving Section 2:
Chapter 1 - An Introduction to Computers and Problem Solving
Chapter 2 - Problem Solving
Chapter 2 - Problem Solving
INTRODUCTION TO PROGRAMMING
ITEC113 Algorithms and Programming Techniques
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
Program Design and Development
Algorithm Design CS105. Problem Solving Algorithm: set of unambiguous instructions to solve a problem – Breaking down a problem into a set of sub- problems.
1 Chapter 8 Designing Small Programs. 2 A ‘Procedure’ v A set of instructions which describe the steps to be followed in order to carry out an activity.
Programming Fundamentals (750113) Ch1. Problem Solving
Moving To Code 3 More on the Problem-Solving Process §The final step in the problem-solving process is to evaluate and modify (if necessary) the program.
Chapter 3 Planning Your Solution
ALGORITHMS AND FLOW CHARTS 1 Adapted from the slides Prepared by Department of Preparatory year Prepared by: lec. Ghader Kurdi.
Fundamentals of C programming
Chapter 1 Pseudocode & Flowcharts
Original Source : and Problem and Problem Solving.ppt.
Adapted from slides by Marie desJardins
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
An ordered sequence of unambiguous and well-defined instructions that performs some task and halts in finite time Let's examine the four parts of this.
Algorithmic Problem Solving CMSC 201 Adapted from slides by Marie desJardins (Spring 2015 Prof Chang version)
INTRODUCTION TO ALGORITHMS PROGRAMMING. Objectives Give a definition of the term algorithm Describe the various parts of the pseudocode algorithm or algorithm.
Chapter 1 Program Development Asserting Java © Rick Mercer.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Chapter 2: General Problem Solving Concepts
Procedural Programming. Programming Process 1.Understand the problem 2.Outline a general solution 3.Decompose the general solution into manageable component.
CS221 Algorithm Basics. What is an algorithm? An algorithm is a list of instructions that transform input information into a desired output. Each instruction.
PROGRAM DEVELOPMENT CYCLE. Problem Statement: Problem Statement help diagnose the situation so that your focus is on the problem, helpful tools at this.
1 Program Planning and Design Important stages before actual program is written.
INTRODUCTION TO PROGRAMMING. Program Development Life Cycle The program development life cycle is a model that describes the stages involved in a program.
The Hashemite University Computer Engineering Department
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '081 Chapter 2 - Problem Solving 2.1 Program Development Cycle 2.2 Programming Tools.
WHAT IS THIS? Clue…it’s a drink SIMPLE SEQUENCE CONTROL STRUCTURE Introduction A computer is an extremely powerful, fast machine. In less than a second,
Flowchart. a diagram of the sequence of movements or actions of people or things involved in a complex system or activity. a graphical representation.
Algorithms and Pseudocode
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
MIT App Inventor Lesson 3 Algorithms Variables Procedures.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
An Introduction to Programming with C++ Sixth Edition Chapter 5 The Selection Structure.
| MSC 8102:PROGRAMMING CONCEPTS By Vincent Omwenga, PhD. 1.
Flow Charts And Pseudo Codes Grade 12. An algorithm is a complete step-by- step procedure for solving a problem or accomplishing a task.
Lecture 3 Computer Programming -1-. The main steps of program development to solve the problem: 1- problem definition : The problem must be defined into.
Selection Using IF THEN ELSE CASE Introducing Loops.
 Problem Analysis  Coding  Debugging  Testing.
Algorithms and Flowcharts
INTRODUCTION TO PROBLEM SOLVING
Chapter One Problem Solving
Introduction to Algorithms
Chapter 2: Input, Processing, and Output
ALGORITHMS AND FLOWCHARTS
Lecture 2 Introduction to Programming
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Algorithm and Ambiguity
Chapter 1 Program Development
ALGORITHMS AND FLOWCHARTS
Chapter 4: Algorithm Design
ALGORITHMS AND FLOWCHARTS
Introduction to Algorithms and Programming
Chapter 4: Algorithm Design
Problem Solving Skill Area 305.1
Algorithm and Ambiguity
Click to add Text Computers & Instructions. Computers are given instructions in the form of computer programs that are created through the development.
Flowcharts and Pseudo Code
Basic Concepts of Algorithm
WJEC GCSE Computer Science
Introduction to Programming
Presentation transcript:

PROBLEM SOLVING

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

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!

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

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

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

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.

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

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

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

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

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.

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.

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

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)

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

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.

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

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

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

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.

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 Print the average price

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

  programming/programming/variables/p/challenge-funky-frog programming/programming/variables/p/challenge-funky-frog