Lecture 3 CCS 102 Flowcharting Part 2 PDF
Document Details
Uploaded by Deleted User
Holy Name University
Tags
Summary
This document is a lecture on flowcharting, a visual tool for designing computer algorithms. It provides examples of process, input, and output symbols, and emphasizes the importance of consistency in representing data in flowcharts.
Full Transcript
Holy Name University College of Engineering and Computer Studies Lecture #3: Flowcharting This is the continuation of the previous video which discusses about writing flowcharts....
Holy Name University College of Engineering and Computer Studies Lecture #3: Flowcharting This is the continuation of the previous video which discusses about writing flowcharts. The next symbol is the “Process symbol”. The label of the process symbol consists of a verb, which is usually “Compute” followed by “what” to compute “as” “how” to compute. Remember that the computer is depended on the instructions we provide. We have to make sure that the instructions are correct. The first example shows the logic of computing for calculateNumber by multiplying inputNumber by 2, thus the representation. On the second example, it shows the logic of computing for weeklySalary by multiplying hrsWrkd by rateHr, thus the representation. Applying the process symbol. Given are the same set of problems as the problems in applying the input symbol. After analyzing the first problem, the IPO were identified. Now since we will apply the process symbol, we focus on the Process item. In order to satisfy the required result, we need to multiply the entered number by 10. You have to bear in mind that in programming consistency is important. The term used to represent the entered number is “number”, so when we calculate the result we use the same term, thus the representation. I have made the terms used to represent data bold to emphasize consistency. After analyzing the second problem, the IPO were identified. Again, since we will apply the process symbol, we focus on the Process item. In order to satisfy the required result, we need to add number1, number2 and number3. Again we should be consistent with the terms used to represent our data. The term used to represent the 3 numbers are “number1, number2 and number3”, so when we calculate the sum we use the same term, thus the representation. The terms used to represent data are again in bold to emphasize consistency. If you have any questions regarding this example, take note of that and send it as comment in the post provided. Copyright ©2020 HNU – Department of Computer Studies 1 Holy Name University College of Engineering and Computer Studies After analyzing the third problem, the IPO were identified. Since we will apply the process symbol, we focus on the Process item. In order to satisfy the required result, we need to multiply length by width. Again we should be consistent with the terms used to represent our data. The term used to represent the inputs are “length and width”, so when we calculate the area we use the same term, thus this representation. The terms used to represent data are again in bold to emphasize consistency. If you have any questions regarding this example, take note of that and send it as comment in the post provided. The next symbol is the “Output symbol”. The symbol used is the same as the input. The label consists of a verb, usually ”print” to denote displaying something, and followed by the data to be displayed. Take note that only known data can be printed. On the first example, calculatedNumber should be displayed, therefore we have that representation. On the second example, weeklySalary is to be displayed, thus we have that representation. Applying the output symbol. Given are the same set of problems as the problems in applying the input symbol. After analyzing the first problem, the IPO were identified. Since we will apply the output symbol, we focus on the Output item. Applying the symbol, we have this representation. We have to observe consistency again. The term use to represent the result is “result” so this should be the term used as label to our output symbol. If you have any questions regarding this example, take note of that and send it as comment in the post provided. After analyzing the second problem, the IPO were identified. Since we will apply the output symbol, we focus on the Output item. Applying the symbol, we have this representation. We have to observe consistency again. The term use to represent the result is “sum” so this should be the term used as label to our output symbol. If you have any questions regarding this example, take note of that and send it as comment in the post provided Copyright ©2020 HNU – Department of Computer Studies 2 Holy Name University College of Engineering and Computer Studies After analyzing the third problem, the IPO were identified. Since we will apply the output symbol, we focus on the Output item. Applying the symbol, we have this representation. We have to observe consistency again. The term use to represent the result is “area” so this should be the term used as label to our output symbol. If you have any questions regarding this example, take note of that and send it as comment in the post provided. To put together all the 3 symbols, these other symbols are used. The succeeding slides show the logic of solution of the problems using the flowchart. The flowchart begins with the start terminator, then flows to the next instruction which is to get an input from the user. The input is represented by number. It then flows to the next instruction which is a process. It calculates result as number times 10. After the computation, it flows to the next instruction which is to display result. The flowchart ends with the stop terminator. The flowchart begins with the start terminator, then flows to the next instruction which is to get 3 inputs from the user. The inputs are represented by number1, number2 and number3. It then flows to the next instruction which is a process. It calculates sum as number1 plus number2 plus number3. After the computation, it flows to the next instruction which is to display sum. The flowchart ends with the stop terminator. Copyright ©2020 HNU – Department of Computer Studies 3 Holy Name University College of Engineering and Computer Studies The flowchart begins with the start terminator, then flows to the next instruction which is to get the length and width of a rectangle from the user. The inputs are represented by length and width. It then flows to the next instruction which is a process. It calculates are as length times width. After the computation, it flows to the next instruction which is to display area. The flowchart ends with the stop terminator. Activity #4: On a ½ lengthwise, solve the following problems: 1. Draw a flowchart that represents the logic of a program that allows the user to input 2 values that represents the price of a product purchased by a customer and the quantity purchased. The program calculates the amount payable (multiply price by quantity) by the customer. It should print the result. 2. Draw a flowchart that represents the logic of a program that allows the user to input a height in feet. The program calculates the equivalent height in inches (1 foot = 12 inches). It should print the result. Deadline of submission is the following day. The succeeding slides are the other flowchart symbols. The decision symbol is a diamond and it has 1 input flow and 2 output flows. The label of the symbol is a question or a condition in which its answer could either be “yes” or “no”. There is a flow when the answer is “yes” and a different flow when the answer is “no”. We will have some examples of problems using this symbol a few weeks from now. The last symbol that may be used in a flowchart is the connector. For example, if the flowchart could not anymore fit on the page, just like shown on the slide Copyright ©2020 HNU – Department of Computer Studies 4 Holy Name University College of Engineering and Computer Studies The continuation of the flowchart is shown on this slide. A connector is used, with the same name as the first part, to denote that this flowchart is the continuation of the previous flowchart. We are done with the second part of Introduction to Computer Programming. I hope you were able to achieve the following expectations: 1) understand the different levels of data, 2) identify the different tools that are used in planning the logic of the solution, 3) identify the different flowchart symbols, and 4) use flowchart in representing the logic of a solution. Copyright ©2020 HNU – Department of Computer Studies 5