COMPUTER-LESSON-2.pptx
Document Details
Uploaded by Deleted User
Full Transcript
LESSON 2 WRITING ALGORITHM, FLOWCH PSEUDOCODE MYRA JAYLO ART OBJECTIVES Identify the different processes in solving programming problems; Explain algorithm, pseudocode, and flowchart are; Recognize the importance of algorithm , pseudocode, and flowchart in programming; an...
LESSON 2 WRITING ALGORITHM, FLOWCH PSEUDOCODE MYRA JAYLO ART OBJECTIVES Identify the different processes in solving programming problems; Explain algorithm, pseudocode, and flowchart are; Recognize the importance of algorithm , pseudocode, and flowchart in programming; and Create an algorithm, pseudocode, and flowchart 01 GIVE ME THE STEPS! How do you put an elephant inside the refrigerator? How do you put a hippopotamus inside the refrigerator? How do you put a giraffe inside the refrigerator? LESSON 2: WRITING ALGORITHM, PSEUDOCODE, FLOWCHART Solving Programming Problems Problem Solving Process in Programming Basic Symbols Used in Flowcharting 07 SOLVING PROGRAMMING PROBLEMS Programming is a problem-solving process. The process of sue the computer, problems includes identifying the problem then writing instructions for the computer, which is called a source code. Programmers use programming language or binary these instructions then convert the instructions into a machine language format that can be executed by the computer. PROBLEM SOLVING PROCESS IN PROGRAMMING WHAT IS AN ALGORITHM? An algorithm is a step-by-step procedure to solve problems. It makes the whole procedure more efficient as well as consistent. It also helps in identifying decision points, processes, and essential variables to solve the problem. A programmer can also see and determine easily the errors in a particular process using an algorithm. WHAT IS A PSEUDOCODE? A pseudocode is a description of an algorithm using a natural language, which makes reading of the program easier. it uses short English-like statements to write codes for programs before you actually create it in a specific language. WHAT IS A FLOWCHART? A flowchart is a diagram representing the logical sequence in which a combination of steps or operations is to be performed. BASIC SYMBOLS USED IN TERMINA TOR Terminator- this is used In declaring the beginning and the end of the flowchart. It is labeled with the word "Start" or "End", INPUT/ OUTPUT Input/Output - this is used If the flowchart needs input from the user or output from a process. PROCESS Process - this is used to process data, normally composed of mathematical symbols. DECISION Decision - if the procedure leads to a comparison, which involves logical or relational operators and questions that are answerable by “Yes” or “No”. ON PAGE CONNECTOR On-page Connector - is a connecting flowchart within the same page. OFF PAGE CONNECTOR Off -page Connector - is a connecting flowchart on another page ARROWS Arrows - declares the flow of the process. EXAMPLE 1 Read the two sides of a rectangle and calculate its area. Write the algorithm, pseudocode and flowchart. ALGORITHM Read the two sides of a rectangle and calculate its area. Algorithm Step 1: Input Width, Length Step 2: Area = Length x Width Step 3: Print Area PSEUDOCODE Pseudocode: Input the width (W) and length (L) of a rectangle Calculate the Area (A) by multiplying L with W Print A FLOWCH EXAMPLE 2 Convert the length in feet to centimeters. Write the algorithm, pseudocode and flowchart. ALGORITHM Convert the length in feet to centimeter. Algorithm Step 1: Input Lft Step 2: Lcm = Lft x 30.48 Step 3: Print LCM PSEUDOCODE Pseudocode: Input the length in feet (Lft) Calculate the length in cm (Lcm) by multiplying Lft with 30.48. Print length in cm (Lcm) Flowchart FLOWCH EXAMPLE 3 Compute for the monthly paycheck of a salesperson at a department store. The employee would receive a bonus of 300 for each year if he/she has been with the store for two years or less. If the employee has been with the store for more than two years, the bonus is P500 for each year. ALGORITHM Algorithm: Step 1: Get the base salary. Step 2: Get the number of years of service. Step 3: Calculate the bonus using the following formula: If (noofyearsofservice is less than or equal to two) Bonus = 300 * noofyearsofservice Otherwise Bonus = 500 * noofyearsofservice Calculate the paycheck using the following equation: Paycheck = base salary + bonus PSEUDOCODE Pseudocode: Input base salary (bs). Input number of service per year (spy). Calculate the bonus (b) using the following formula with the following conditions: If (noofserviceperyear (spy) is less than or equal to two) Equivalent of bonus is 300 multiplied by noofserviceperyear (spy) Otherwise, equivalent of bonus is 500 multiplied by noofserviceperyear (spy) Calculate the paycheck using the equation value of: (Paycheck is equivalent to the sum of basesalary (bs) and bonus (b)) FLOWCH ACTIVITY 1. ALGORITHM AND PSEUDOCODE Rearrange the correct sequence of steps in following a pseudocode. Write the correct arrangement of letters in the space provided after each procedure. Make a cup of coffee: _______________________ A. Add a coffee and/or sugar B. Stir it using a spoon C. Pour hot water in the cup ACTIVITY 1. ALGORITHM AND PSEUDOCODE Display the area:________________________ A. Display the area (area) B. Input for the length of side one (side1) C. Compute for the area by multiplying side one and side two. D. Input for the length of side two (side2) ACTIVITY 1. ALGORITHM AND PSEUDOCODE Compute for the amount of change: _______________ A. Display the change (c) B. Input amount given (b) C. Compute for the change (c) by subtracting the amount given (b) and the amount purchased (a). THANK YOU Presentation by Myra Jaylo