FT304001 Price: RM25.00 4 LEV 4 COMSCI Machine Translated by Google
SCIENCE COMPUTER 4 LEVEL 4
Ensure a liberal approach to its rich cultural traditions and diverse patterns; That our country Malaysia supports the ideal of wanting; Creating a fair society where the prosperity of the country will be shared fairly and equitably; Build a progressive society that will use modern science and technology; THEREFORE WE, the people of Malaysia, pledge to focus all our energy and efforts to achieve these goals based on the following principles: Achieve closer unity among the entire community; Preserving a democratic way of life; (Source: Information Department of the Ministry of Communications and Multimedia Malaysia) NATIONAL PILLARS SUPREMACY OF THE CONSTITUTION BELIEF IN GOD COURTESY AND MORALITY LOYALTY TO KING AND COUNTRY RULE OF LAW Machine Translated by Google
SCIENCE COMPUTER Oxford Fajar Sdn. Bhd. (008974-T) STANDARD HIGH SCHOOL CURRICULUM LEVEL 4 THE WRITER DESIGNER Zaliha binti Mohamad Intan Farhanna binti Uyob Yew Kwang Hooi ILLUSTRATOR EDITOR Chua Siwe Geck Brenda Tan Fatimah binti Ismail @ Mohd Nor Nurul Atiqah binti Ibrahim Machine Translated by Google
Appreciation University Lot 45, Persiaran Mewah, Bandar Tun Razak, Cheras Malaysian education. Malaysian education. •Ready Manuscript Review Committee 4, Jalan Pemaju U1/15, Section U1, Hicom-Glenmarie Industrial Park, Petronas Letter, Textbook Division, Ministry First Print 2016 Selangor Darul Ehsan. Fax: 03-56294009 Oxford Fajar Sdn. Bhd. Text Typeface Size: 11 pt •Proof Correction Review Committee All rights reserved. Any material in this book may not be reproduced, stored in a way that can be used again, or transferred in any form or manner, either by electronic, mechanical, rephotographing or recording without prior permission from the Director General of Education Malaysia , Malaysia Education Ministry. Consultations are subject to royalty or honorarium arrangements. •Lecturers from UNITAR International Rina Printing Sdn. Bhd., The publication of this textbook involves the cooperation of many parties. A wreath of appreciation and thanks goes out to all parties involved: Oxford Fajar Sdn. Bhd. Malaysian education. •Lecturers from the University of Technology 56000 Kuala Lumpur Camera, Textbook Division, Ministry 40150 Shah Alam, Layout and Typing: Curriculum Development Division, Ministry Text Typeface: Helvetica Neue LT Std 47 Light Condensed •Face Proof Improvement Committee KPM2016 ISBN 978-983-47-2013-1 Tel: 03-56294000 Malaysian education. © Ministry of Education Malaysia Website: http://www.oxfordfajar.com.my Printed by: •Officers of the Textbook Division and Published for the Ministry of Education Malaysia by: Pages, Textbook Division, Ministry No. Book Series: 0010 Machine Translated by Google
315 II 129 75 218 342 Reference list PROGRAMMING 1.1 Problem Solving Strategies 1.2 Algorithms 1.3 Variables, Constants and Data Types 1.4 Control Structures 1.5 Programming Best Practices 1.6 Data Structures and Modularity 1.7 Application Development Summative Exercise Review 1 187 291 310 346 2 DATABASES 2.1 Relational Databases 2.2 Relational Database Design 2.3 Relational Database Development 2.4 Database System Development Summative Exercise Review 2 314 Copyright and Credits Page 56 194 326 Glossary 111 240 343 345 i IV 168 309 1 189 HUMAN COMPUTER INTERACTION 3.1 Interaction Design 3.2 Display and Screen Design Summative Exercise Review 3 Introduction Title Page 20 193 CHAPTER CHAPTER CHAPTER Content iii 1 2 3 Machine Translated by Google
Form 4 Computer Science Textbook is written based on the Curriculum and Assessment Standard Document (DSKP) published by the Malaysian Ministry of Education. This textbook reinforces and provides students with the knowledge, skills and values of Computer Science and computational thinking. Computational thinking develops students' skills through the ability to design, produce and create new applications. Computationally minded students are able to solve problems and can contribute ideas in the development of new world technologies that can solve problems collaboratively. This book is oriented towards some student-centered learning strategies. This strategy includes independent learning, collaborative learning, project-based learning, inquiry-based learning, problem-solving learning, mastery learning, constructivist learning and exploratory learning. Aspects of Computer Science Process Skills and Higher Level Thinking Skills (KBAT) are also emphasized in this book to build students' thinking towards creativity and innovation. KBAT can stimulate structured and focused thinking among students through four levels of thinking, namely applying, analyzing, evaluating and creating. At the same time, students are able to cultivate several skills such as critical, creative and reasoning skills as well as thinking strategies. The use of i-Think maps is also emphasized in this book. The use of i-Think maps exposes students to simple and easy-to-understand learning techniques. It will be easier for students to remember a fact through the use of attractive iThink maps with colors that can stimulate students' thinking and attract students' attention to use them. Cross Curriculum Elements (EMK) is an added value element that is applied in the teaching and learning process to strengthen students' skills in addition to producing students who are competent and able to accept challenges in the future. EMK includes eight main aspects, namely language, environmental sustainability, moral values, science and technology, patriotism, creativity and innovation, entrepreneurship and information and communication technology. 21st Century Skills are also applied in this book to produce students who have life skills that are based on pure values and have high competitiveness at the global level. iv Introduction Machine Translated by Google
RESEARCH v you ? Did you know? Icons in Textbooks and Their Functions Mind Test KBAT Computer Science Innovations Computer Science Careers Daily Application My Malaysia! CASE Career Science Computer Science Innovation Computer Mind Test My Malaysia Apply knowledge of computer science in Expose students to Level Thinking Skills questions Provide interesting questions to test students' understanding of the field of computer science Daily application of daily life Height Various activities that are exploratory or based on stimulating materials to increase students' understanding of the learning standards that have been learned. A variety of interesting and informative digital resources are accessible Computer Form 4, which is www.skomtg4.com/#2 Provides interesting information about the topic being studied Introducing the types of careers related to the field of computer science from the Science portal Highlighting Malaysia's success in the field of computer science Highlighting the development and innovation of computer science technology today Machine Translated by Google
{ To analyze the parts or structure of a physical object To show the cause and effect relationship To make an analogy use a connecting factor To classify items based on common properties To create a sequence for a process logically To compare and contrast items To show the characteristics of an item or concept To brainstorm to generate ideas. i-Think How to Use the Map i { CIRCLE MAP DOUBLE BUBBLE MAP FOAM MAP TITI MAP DAKAP MAP FLOW MAP VARIOUS FLOW MAPS TREE MAP Machine Translated by Google
» Problem solving strategies » Application development (apps development) » Control structure In this chapter, you will learn: » Modularity and data structure » Variables, constants and data types programming » Algorithms » Best practices The use of computers, smartphones and tablets has become a necessity in today's life. The interaction between humans and communication equipment has created a form of language known as programming language. Various applications have been designed using programming languages to help people in their daily lives. Does using multiple apps help you solve problems? 1 • What are the existing applications that can solve problems, whether simple or complex? • Can you imagine your life without the use of computers and smart phone? • What applications can be created to solve problems three to seven years from now? CHAPTER 1 Think... PROGRAMMING CHAPTER 1 PROGRAMMING Machine Translated by Google
2 Read the input "Hello Malaysia" Pseudocode 3 Display the output "Hello Malaysia" 1 Start Flowchart 4 End Solution Strategy Problem x = "Hello Malaysia"; 1.1.1 Explain the need for strategic problem solving } } String x; public static void main(String[] args){ "Hello public class HelloMalaysia { "Hello Malaysia" Output 1.1.3 Using the problem-solving process: collect and analyze data, define problems, generate ideas – remove obstacles, generate solutions, determine actions, implement solutions, make evaluations, and make improvements Computer Science Form 4 */ Malaysia" Input x= * "Hello Malaysia" Figure 1.2 Program example for Hello Malaysia /*Write a program that will display a message Start Figure 1.1 Example of the Hello Malaysia algorithm Finished System.out.println(x); 1.1.2 Explain the characteristics of effective problem solving 2 CONTENTS STANDARD LEARNING STANDARDS 1.1 The CPU will execute the received command and start the troubleshooting process. Therefore, the programmer has to write a specific 'syntax', which is the rules that the computer needs to execute the instructions correctly. Figures 1.1 and 1.2 show examples of writing algorithms and programs to display Hello Malaysia messages. Figure 1.1 shows two algorithm representation formats namely pseudocode and flow chart. Programmers need to understand how to solve a problem and translate that way into an algorithm that a computer can understand. The component responsible for executing instructions is the main processing unit (central processing unit, CPU). Problems are doubts, unwanted situations, challenges and opportunities faced in one's life. Decision-making skills are essential to produce a generation capable of planning problem-solving strategies. For example, we have to make a decision about the type of food to buy in the canteen with the amount of money available. Problem solving is a mainstay of computer science. Machine Translated by Google
APICTA Awards organized by Multimedia Development Corporation two-way https:// goo.gl/ 2JlmX8 My Malaysia Create communication Improve thinking skills Khan academy: What is programming? Encourage selflearning CHAPTER 1 PROGRAMMING (MDeC) has been showcasing national ICT innovation and excellence since 1999. This award is held to highlight the talent and also recognize the creativity of local people, including achievements and historic contributions in an industry. Figure 1.3 Strategy requirements in problem solving Helping the development of a concept Computer application development is closely related to problem solving strategies in computer programming. A person needs to master the problem solving strategy in order to understand the problem easily to get the best solution strategy. Computers can be used to solve problems. However, the solution to the problem must be clear before overcoming it. Computational thinking allows us to understand the problems at hand and develop reasonable solutions when we face complex problems. Various problems in daily life are challenges that need to be overcome. Problems prevent us from achieving what we want, in addition to disrupting the smoothness and comfort of life. A complex problem requires an effective problem-solving strategy. Problem solving as the process of examining the details of a problem to find a solution (Businessdictionary.com) What are the benefits of using strategies in problem solving? 1.1.1 Strategic Problem Solving Requirements 3 Why is strategy necessary in problem solving? Machine Translated by Google
www.utusan.com.my taken in excess of the required calories.' Prime Minister, Mr Computer Science Form 4 On August 11, 2016, 'The number of calories Source: in the life of a student. My Malaysia in the mentioned environment? problem solving starting January next year. Malaysia is the first country in ASEAN to pioneer this curriculum. suitable food is eaten so that the necessary calories are present Use of strategies Figure 1.4 The resolution technique of breaking a bicycle into bicycle parts Daily Application For example, the calories of a piece of roti canai is 300 kcals. What type Computer Science will be integrated into the school's official curriculum Computational and to 18 years is 2600ÿ2800 kcals. Seri Najib Tun Razak has announced that Pemikaran The number of daily calories needed by teenagers between the ages of 16 Solve problems in brushing teeth. Fill in the appropriate diagram as in the example above. Example: Understanding how a bicycle works will be easier if the entire bicycle is broken down into small parts. Refer to the diagram below and label the parts of the bicycle that are drawn. 1. Decomposition Techniques – Breaking problems into smaller and manageable parts. Before a computer can solve a problem, the problem and how to solve it must be understood. Problem decomposition helps break down complex problems into manageable parts. Similarly, we try to understand how complex systems work using solution techniques. Solution technique The four computational thinking techniques in problem solving are: 4 Machine Translated by Google
5 CHAPTER 1 PROGRAMMING 2. Pattern recognition (Pattern recognition) - Looking for similarities (similarities) between problems and within problems. When we have broken down a complex problem into manageable parts with a solution technique, this helps in identifying commonalities or patterns that exist in each small part of the problem. These patterns can help solve complex problems more efficiently. The characteristics of the bicycle are that it has two rotating wheels, handlebars to control the direction, pedals to move the bicycle and a chain that is a connector so that the bicycle can work. In computational thinking, these characteristics are known as patterns. Some have large wheels, mirrored handlebars, pedals and a red frame. So, we can draw a picture of a bicycle based on the above characteristics. Imagine we want to know how a bicycle works. There are bicycles with two small wheels, basket handlebars, pedals and a pink frame. By following patterns and ignoring specifics, we can solve problems about bicycles. The only specific differences are the color of the bike, the sound of the bell or the size of the wheels. Bicycles can also have different sized wheels, curved handlebars, green colored pedals and frames. Machine Translated by Google
Computer Science Form 4 handlebars wheels pedals In computational thinking, after knowing the general characteristics for the brushing problem, a pattern has formed. When we can learn how to brush our teeth, other individuals can also do so by following those patterns. For example, the bicycle model and the functions formed after the scaling process. 3. Scaling (Abstraction) – Scaling is important in order to generate the right solution to the problem at hand. For example, to produce a bicycle, if we do not scale the general and specific characteristics, we are likely to produce a bicycle with small wheels and baskets on the handlebars, which is an inaccurate solution. A bicycle model is a bicycle that has two wheels, handlebars and pedals. Specific features such as wheel size, baskets or bells and frame color should be ignored. State two features that will be a pattern and two specific features found in brushing teeth. the above pattern to draw a bicycle and also build an algorithm to solve the problem at hand. A model is a representation of a problem or a general idea of the problem to be solved. Pattern recognition Once we have a model for the problem, we can use it 6 Machine Translated by Google
INPUT “Yes” OUTPUT “Handlebar to control the direction?” Start INPUT “Yes” Finished OUTPUT “Pedals and chains to move a bike? OUTPUT “Having 2 spinning wheels?” OUTPUT “This is a bicycle.” INPUT “Yes” Mind Test Source: www.acm.org Figure 1.5 Example of pseudocode for the function problem of a bicycle What are examples of computational thinking in your everyday life? by humans or machines. computational thinking as building power and computational solution processes, whether implemented CHAPTER 1 PROGRAMMING As a Computer Science student, in your opinion, why do we need computational thinking? The founder of computational thinking is Jeannate M Wing. He has interpreted After scaling general and specific patterns, draw a problemsolving model for brushing teeth. In the algorithm, each instruction is identified and ordered 4. Algorithms (Algorithms) – Developing step-by-step solutions to problems faced or following rules to solve problems. An algorithm is a plan, which is a set of instructional steps to solve a problem. If you can tie a shoelace, make a cup of coffee, or prepare a meal, you already know how to follow an algorithm. Scaling Scaling used as a starting point for designing computer programs in the form of flowcharts and pseudocode. Write pseudocode to build a solution model for brushing teeth. implementation is carried out as planned. Algorithms too Algorithm 7 you ? Did you know? Machine Translated by Google
Get to know Waze goo.gl/CtP3Cs Figure 1.6 Waze view from KL Sentral to KLCC Justify the characteristics of computational thinking in problem solving Computer Science Form 4 Your class has been tasked with conducting a Campaign to Reduce Electricity Consumption in your school as the electricity bill has increased and it is appropriate that this problem be studied and resolved immediately. Justify the characteristics of computational thinking in solving problems based on the given situation. (a) Solve the problem of increasing electricity bills. Teamwork 1 (b) Identify the characteristics that exist and build patterns of electricity use or waste in all places involved in your school. above problem. (c) Scaling the features to be modeled and the specific features to be set aside. (d) Briefly explain the step by step solution taken to solve (KLCC) from KL Sentral, you need to plan the journey you should take, which is to follow the nearest road and not experience traffic jams. Let's say you use the Waze app to get to KLCC. First enter the desired location which is KL Sentral to KLCC in the space provided. You will get a display like below. You can choose three travel options suggested by Waze Computational thinking allows us to plan exactly what the computer wants to do. For example, if you want to go to the Kuala Lumpur Convention Center taking into account the number of friends with you and your mode of transport. In this case, planning a journey is computational thinking while following step-by-step instructions is programming. 8 Machine Translated by Google
• Mobile application developer Problem solving with computational thinking Skills in • Network engineer programming has created the following professions: • IT Manager Career Science Computer Play Pacman online goo.gl/ov5vvh Exploring computational thinking: examples of the use of computational thinking • Website builder CHAPTER 1 PROGRAMMING https://goo.gl/OrzWXS • Software engineer 2 Teamwork (c) What are the ways to solve the problem in order to win To win in Pacman game, we should know what kind of items to eat, safe path, anything to avoid, and how to destroy enemies. (b) Name two other types of games that require a solving strategy to win. in the game mentioned in (b)? (a) Based on the four computational thinking techniques and your understanding of the game, discuss with your friends a strategy to win the game. 9 Machine Translated by Google
After thinking of a strategy to solve the problem and implementing the strategy, the results obtained will reflect the effectiveness of the problem solving strategy that has been taken. The mission of finding a solution involves three important features namely cost, time and resources. A project that is implemented according to the normal period is a project that is implemented according to the time and cost allocated. While the fastest completion cost (crashing cost), is the maximum effort to complete the project in the shortest time. The fastest time completion cost (crashing cost) increases when the duration of the project decreases. The question that is always discussed by the committee that implements the project is, (a) how much will the project cost? (b) will the cost increase productivity? (c) can the cost solve the problem at hand? The time factor in solving this problem plays an important role so that all preliminary planning and implementation of problem solving can be done according to the set period. Implementation activities that are delayed or completed late will increase costs. In addition, solving problems that require the shortest time, such as the need to complete a project within a limited period of time, will also involve increased costs. For example, increasing the number of employees so that a project can be completed in the desired time. Cost is defined as the price to be paid to acquire, produce and maintain, usually in the form of money, time, energy, and expenses. (Dewan Bahasa Online Dictionary) Effective problem solving that involves time referencing a project that is completed according to the time that has been set. Cost Time A Gantt chart is a planning table that can see the progress of all project activities displayed by time period. The left side of the chart is a list of activities while the top is the time period. Each activity is represented by a bar, the length of the bar represents the start and end date of the activity. The use of Gantt charts is important in problem solving because information can be seen at a glance, namely, (a) a list of project activities (b) when each activity starts and ends Did you know? Did you know? you ? you ? 1.1.2 Characteristics of the Solution Effective Problems http://goo.gl/1gUAJX Technique) is a project management tool used to manage, schedule and coordinate project activities. A PERT chart can show the sequence of tasks to be performed. The purpose is to determine the minimum and maximum time for ICT Job Market Report in Malaysia 2015 by the Computer and Multimedia Industry Association of Malaysia (PIKOM) Computer Science Form 4 Evaluation Review Delay in completing the project will only increase the cost. PERT Chart (Program implementation of activities in the project. This is important to avoid delays in completing the project. Direct costs are costs for project activities such as project employee salaries. Indirect costs are costs for activities that do not directly involve the project. For example security costs and phone bills. 10 Machine Translated by Google
3 users List of Activities 2. Distribute questionnaires and obtain data 5. Make a summary 3. Be friendly 1. Prepare a questionnaire Jan-17 Feb-17 Mar-17 Apr-17 May-17 4. Analyze data 11 Teamwork What is a Gantt chart? Car route CHAPTER 1 PROGRAMMING http://goo.gl/flCzss Characteristics of effective problem solving based on cost and time https://goo.gl/NRMbzc Teaching Computers to Understand Humans Computer Walkway Language Science Innovation Figure 1.7 An example of a simple Gantt chart Source: Google Maps (c) time period of each activity (d) overlapping activities (e) start date and expected end date of the project See the Gantt chart example below, can you provide the information you can see at a glance? Discuss the impact of their choice of transportation in terms of cost and time from Pantai Damai Resort to Sarawak Cultural Village. Ten members of your school's Environmental Lovers Association would like to have a study tour from Pantai Damai Resort to Sarawak Cultural Village. The distance between the two places is 850 m. Give your justification. In your opinion, what is the appropriate option for solving the above problem? If they leave from Pantai Damai Resort to Sarawak Cultural Village on foot, it will take them 11 minutes, while if they take a car it will only take 3 minutes. Machine Translated by Google
Teamwork Computer Science Form 4 12 Situation 2: Use the tips below to help you solve the problem. (a) The duration of maternity leave is 2-4 months (b) The organizer's actions before she starts her leave What steps should the project manager take to solve the above problem? Justify your answer in terms of the cost involved, the time period to complete the project and also the human resources involved. Company X is developing an application for student attendance that needs to be completed within three months. At the same time, this company has also got a new project which is to build a bus ticket printing application that needs to be completed in the same period of time. Suggest solutions that can be taken in the management of the costs involved and skilled manpower resources considering that these two projects need to be completed in the same period. Use the tips below to help you solve the problem. (a) List the requirements of both projects (b) List the activities and duration in a Gantt chart (c) Actions that can be taken by the project manager A programmer needs four months to complete the tasks entrusted to him but will be on maternity leave during that time. Situation 1: (c) Actions that can be taken by the project manager 4 Features important to solving problems In problem solving planning, all solutions require resources. Resources are needed to generate a product or service. Examples of resources are financial resources, human resources and technological resources. Resource planning is the responsibility of management and good resource planning is to obtain optimal results. Waste of resources can be avoided with careful planning. The problem faced when there is a lack of resources is that it will delay the time to complete the project, resulting in an increase in the cost of the project. 1 Ensure that there is an officer or unit that monitors resource scheduling. 4 Organize the activity scheduling process so that it is balanced and can be implemented throughout Scheduling of project resources should be held to avoid shortages so as not to affect the solution of the problems faced. The following steps should be taken into consideration for this purpose. Resources are defined as stock or money, raw materials, staff and other assets that can be used in the organization so that it can function effectively (Dewan Bahasa Online Dictionary). 3 Ensure project requirements are carefully managed taking into account existing resources and allocated financial resources. Source 2 Using a queue system according to project priority (first come first served). project is carried out. Machine Translated by Google
Mind Test Let's play a programming game using code. CHAPTER 1 PROGRAMMING https://goo.gl/LrEUhH Toll Toll Toll 13 House Toll: RM2.00 Uncle Ali Uncle Ali (b) Discuss in terms of cost (Toll), time (traffic lights) and resources (distance) of the three roads that have been searched. Pak Ali wanted to go home from the city. Pak Ali has three options to return home. Help Pak Ali find his way home by shading the suggested path. (c) Justify the choice of road that Pak Ali will use from the aspects of cost and time (a) Find the three roads that can take Pak Ali home. and resources. Machine Translated by Google
The problem solving process in programming is as follows: The problem solving process involves appropriate steps and depends on the type of problem to be solved. Every problem that wants to be solved needs to go through several processes, that is, according to the structure of the generic model as a guide. Programming can help students think creatively and innovatively and help them to solve problems and perform all processes correctly. Pupils need to collect data about the cause and scope of the problem and identify the following in a situation. • How impactful is the problem? • When does the problem need to be solved? Students need to identify the most important problem that needs to be solved. Then, the second problem also needs to be identified before identifying the student's existing level of understanding. • Is this a major problem? • What other problems can be detected? The generic model of problem solving in Figure 1.8 consists of eight processes. Each process will be explained with questions that should be thought about together. 8 improvements Perform 6 solutions 4 solutions 2 Define the problem Jana Determine 2 problems Make Collect and data analysis Make 7 evaluations Generate ideas Determine 5 actions (remove 3 obstacles) 1 Collect and analyze data Generic means general or related to specific characteristic features belonging to a group. Figure 1.8 Problem solving process Computer Science Form 4 Source: Online Dictionary language Council you ? Did you know? 1.1.3 Problem Solving Process 14 Machine Translated by Google
Evaluation will be carried out against the solution measures. • Can this idea solve the problem at hand? Students should list ideas or steps when planning a solution. The teacher needs to identify that the student has generated an appropriate solution plan. • Has this solution idea been discussed clearly? • Are other options worth considering? Students need to list some ideas that can be used to solve each problem that has been identified. • To what extent can the listed ideas solve the problem? Students need to use various tools and techniques that have been chosen to implement the solution. The focus should be on actions that can contribute to solving the problem. • Can this action be successfully implemented? • Are the results to be achieved satisfactory? Students should make the best choice from the list of ideas that have been made. Every solution that has been implemented needs to be improved if there are still deficiencies and as needed. • What improvements can you suggest? If it does not meet a satisfactory level or does not solve the problem, the student needs to find another course of action. 15 Troubleshooting Process https://goo.gl/UD7NRt Connect all the dots using only four lines without lifting your pen. To stimulate your thinking about the problem-solving process, think of solutions to the following problems: Mind Test Problem Solving Model Visit the following website to learn more about the model. http://goo.gl/pCKdx CHAPTER 1 PROGRAMMING There are various creative problem solving models, among which is the Creative Problem Solving Model by Osborn and Parnes. you ? Did you know? 4 Generate a solution 5 Determine the action 6 Implement solutions 8 Make improvements 7 Make an assessment 3 Generate ideas – remove obstacles Machine Translated by Google
Example 1 Read the letter below carefully. You as an officer at the Sandakan Municipal Council (MPS) have been assigned to resolve the issue. Based on the troubleshooting steps steps 1-8, solve the problem faced by them. Explain each step and provide a suitable example, find the solution step and prepare your answer in the form of a letter to Mr. Ahmad and his friends. Bumps in the Road ( Speed humps ) in Jalan Maju, Sandakan Yours sincerely, Sir, ' shock absorbers Sandakan Municipal Council Thank you. 4. My friends and I hope that MPS will solve this problem immediately. Officer ' motorcycle and car bicycle users To, So far this year alone there have been five cases of road accidents because the car did not have time to stop at the bump in the road. 2. I, Ahmad bin Haron, representing 10 of my friends who live along Jalan Maju which is 1.8 km long, would like to propose to the Sandakan Municipal Council that the road bumps built on Jalan Maju be leveled or removed for the following reasons: - Road bumps slow down and create traffic jams - Increase accidents in the area of road bumps - During rain, water stagnates on the bumps and is dangerous 23, Jalan Maju, 90700 Sandakan. 3. For your information, we had to go through nine bumps each time to leave the house and nine more times when returning home. - Delaying the ambulance AHMAD BIN HARON The above referenced matter. we - Causes air and noise pollution in residential areas - Damage Ahmad bin Haron & friends 16 Computer Science Form 4 Machine Translated by Google
CHAPTER 1 PROGRAMMING • Repair water drainage in hump areas. • Stagnant water endangers motorcycle and bicycle users (will be resolved by repairing An assessment needs to be made whether the installation of warning boards and lampposts has an impact on road users and whether the number of accidents has decreased. • Slowing travel, creating traffic jams, increasing road accidents, stagnant water, endangering motorcycle and bicycle users, damaging cars, delaying ambulances, increasing air and noise pollution. 8 Make improvements Based on the actions that have been taken, have those actions solved the problems faced by the residents of Jalan Maju? If so, improvements can be made to the existing solution. If not, discussion and new ideas can be presented. • The number of bumps will be reduced. Based on troubleshooting steps 1-8: Ideas from MPS Officers: • Damage the car (not acceptable because if the driver is driving at the specified speed limit). Referring to the letter from Mr. Ahmad: • The problem of road bumps is too many and five cases of road accidents have occurred. • Creating traffic jams (unacceptable because traffic jams happen everywhere along the road.) 2 Define the problem • Increase traffic accidents (acceptable, warning signs or flashing lights will be on Actions to be taken by MPS: 6 Take action 7 Make an assessment water drainage in the hump area and refer to the warning). • Installation of warning boards and flashing light poles. Solution: 3 Generate ideas (remove obstacles) 1 Collect and analyze data • Slowing down the ambulance (acceptable by reducing the hump). • Delaying the journey (unacceptable because priority is given from the safety aspect 5 Determine the action road). • Air and noise pollution (unavoidable because of the main road, but can plant trees A discussion can be held between MPS with Mr. Ahmad and his colleagues to determine the actions that need to be taken and follow-up actions that depend on cost, time and resources. Can build a Gantt chart and list the solutions based on point number 4. Examples of installing warning boards and flashing light poles can be carried out first. • Needs to be resolved immediately. main road and at certain times only). 4 Generate a solution The act of installing warning boards and lampposts involves cost and resources. Justification of the cost and also the impact on the problem faced needs to be made. Referring to the letter from Mr. Ahmad, other problems faced are as follows: • Plant trees along the road. install in the hump area). 17 Machine Translated by Google
CASE Formative Training 1.1 18 Computer Science Form 4 2 Explain the following terms with suitable examples. Collect and analyze data Explain each step by giving an example of the activity carried out. 1 List four computational thinking techniques using the i-Think map. 3 Complete the steps for each troubleshooting process in the following flowchart. Example Based on the information obtained, carry out a problem solving process that covers eight processes. Propose a reasonable solution to the problem to the local Municipal Council to deal with the problem. Present your group's results using PowerPoint, Google Slides or i-Think maps. Fastest time cost http://www.thestar.com.my/metro/community/ 2016/07/05/dengue-danger-in-carpark-shah alamfacility-infested-with-mosquitoes-and littered-withrubbish/ This article is excerpted from a local newspaper. Get more information through the following website: Indirect cost Direct cost 4 Watch the video at http://edtechreview.in/trends-insights/insights/2376-coding-computer programming for-kids. This video displays the experiences of famous people from the world of technology. What ideas in this video can motivate you in using programming as a problem solver? Details Make improvements Terminology RESEARCH Machine Translated by Google
CHAPTER 1 PROGRAMMING ( f ) Type of activities to be done during the visit (ii) Have breakfast in the school canteen: no need to prepare. (b) Suggest solutions that can be taken by the government and drivers (a) In your opinion, what is the likely cause of the accident? (b) Options: (d) Committee members (c) Ways to get sponsorship as a small donation for the tour (d) Suggest improvement measures to the program in (c) that can help (a) Visiting place/location 6 Think of some of the routines you carry out as a student. Record your steps to perform the routine. In each step that has been noted, state the chosen solution step and justify why you chose that recommendation. Refer to the following example as a guide. 7 As a naïve programmer, what are the characteristics that can describe you as a programmer who can solve problems effectively? What skills are required? (i) Having breakfast at home: can save money. (c) The government has carried out various programs such as Ops Pacak, Ops Statik, Ops Sikap and Ops Selamat to reduce accidents on the road, especially during the festive season. Based on the questions that have been listed, you as Puan Sabariah are required to make a decision and get agreement together with the 4 Mesra students. Use computational thinking techniques to solve the problem and explain the solution in detail. (g) Duration to plan the visit and time for activities during the visit (c) Justification: to solve the problem you mentioned in (a). Give justification for each opinion presented. (i) Have breakfast at home: boil water, make a drink and eat biscuits. (e) Duties of committee members and students (a) Have breakfast at home or in the school canteen 9 We often read the local newspaper about road accident news. Surf the Internet to get news about a traffic accident case. Briefly describe the case. (b) Necessary costs Have breakfast before going to school. 8 Study the data on the symptoms of truancy among 4th grade students at your school. Determine the main problem contributing to the symptoms and suggest three possible solutions. Provide justification for each recommendation. in solving the problem of traffic accidents more effectively. (ii) Have breakfast in the school canteen: prepare money for shopping. State the steps that have been taken in the program. 5th grade teacher, Puan Sabariah, class 4 Mesra would like to plan a visit during the upcoming school holidays. The questions that should be given consideration when planning the visit are: You can use a computer to collect and analyze data. 19 Machine Translated by Google
Example 2 Take the elevator 6 Exit the elevator Example 1 Hitting the water 1 Start 7 End 7 End 4 Enter the elevator and press the level number Other examples of algorithms in daily life are as follows: 5 Wait until the elevator door opens at the desired level 5 Wait until the water boils 1 Start 2 Press the button Algorithms can be refined by adding details. Example 6 Turn off the flame 3 Wait for the elevator An algorithm is a set of instructions for solving a problem. A detailed set of instructions that the reader can follow until the task is completed successfully is a form of algorithm in everyday life. In everyday life, there are many examples that can be related to algorithms. For example, a mother can refer to the instructions for cooking preparations in a recipe book. 2 Fill the kettle with water 4 Turn on the flame 3 Place the kettle on the gas stove 1.2 Algorithm 20 1.2.5 Identify the correct output of the algorithm based on the given input 1.2.4 Detect the value of a variable at each level in the algorithm Computer Science Form 4 1.2.1 Using algorithms to express solutions to problems 1.2.2 Build problem-solving algorithms using control structures in programming (sequence, choice and repetition) http://goo.gl/pEVOo3 1.2.3 Testing and fixing errors in algorithms What is an algorithm? 1.2.6 Translate algorithms into programming languages LEARNING STANDARDS STANDARD CONTENTS Machine Translated by Google
(i) Wait for the canned drinking water to come out in the room provided (iii) If the balance has not yet reached zero, enter the remaining money Based on the examples of algorithms in daily life that have been given, instructions can be identified in a certain order, have clear details and can be implemented in a limited time, ie have a beginning and an end. Look at Example 3. Are the details of the algorithm clear enough? If not, you need to refine the algorithm with ideas to solve the problem. For example, instructions (2) and (4) require additional details. (ii) Note the balance of money required Buy canned drinking water from a vending machine be required Command refinement (4): (i) Insert coins or banknotes in the money slot provided (iii) Wait for the remaining money (if any) in the room provided (ii) Take the canned drinking water Command refinement (2): Vending machines can detect counterfeit coins. How do you think the vending machine works to detect the counterfeit money using algorithms? Example 3 1 Start 2 Enter enough money 4 Take canned drinking water 5 End 3 Press the selected canned water button educational fields in IT or Computer Science. Through the Malaysia Digital Economy Corporation (MDEC), the government has taken the initiative to create a high-tech corridor in Malaysia. Details algorithm CHAPTER 1 PROGRAMMING Economics involves Characteristics implemented Figure 1.9 Mandatory features of the algorithm Transformation Plan Have limitations Yes clear Mind Test My Malaysia 21 Machine Translated by Google
1.2.1 Use of Algorithms to Solve Problems 22 What is the relationship between computer programs and algorithms? A computer program is a computer algorithm written in a programming language that can be executed by a computer. process and output. 2 Write general instructions for processing input to output. a If it is not clear, refine the general instructions by writing instructions 4 Refine each general instruction that is still unclear. 1 Analyze the problem that needs to be solved. Identify inputs, goals 5 The last instruction must produce the desired output of the process and this is the limitation of the algorithm it is designed for. 3 Analyze each general command to assess the clarity of the command so that it can be implemented. The instructions for generating an algorithm based on the characteristics in Figure 1.9 are as follows: b For each detailed instruction, make an assessment of whether or not the detailed instructions still need to be refined. A computer is an electronic device capable of receiving and processing input data to produce information as output as well as storing both data and information. One of the characteristics of computers is the ability to store and use various programs to perform computer processes. All computer programs are software that "turn on" the computer hardware by processing all inputs into outputs. detailed instructions. Figure 1.10 shows an illustration of computer software as an Input-ProcessOutput (IPO) model. The computer system receives Input from the user. Input is a number, character, word, sound or picture Examples: text, numbers, objects Process Figure 1.10 Input-Process-Output (IPO) concept for computer software https://goo.gl/E2jfoU INPUT Computer Science Form 4 How to design a good flowchart? Did you know that algorithms have been used in many aspects of life? For example, directions to a destination, cooking recipes, furniture assembly manuals and microwave operation manuals. OUTPUT Examples: reports, tables, presentations, displays, documents Daily Application Machine Translated by Google
Output The award is organized by the Pistoia Alliance of King's College in London. Career Science Input Input Computer My Malaysia Family photo taken by Adam. Figure 1.11 IPO chart not only write computer programs but are responsible for creating, maintaining and evaluating software. Pictures received by grandparents. Source: www.thestar.com.my Process CHAPTER 1 PROGRAMMING Output Computer programmers write computer applications, mobile phone or smartphone applications, websites and computer systems. In April 2016, the Malaysian team from the Malaysian Integrated Medical Professional Association (Mimpa) led by Dr Dhesi Baha Raja won an international award, the Pistoia Alliance Life Science Award, for having developed an algorithm application to detect dengue outbreaks. The process of sending images using hardware and software. Software engineer Process Example 1 or environment. Before writing an algorithm for a problem, an IPO analysis needs to be done. IPO analysis is to identify the input data, the process to transform the data value into information and display the information output after the process. IPO analysis 1 Input: Should identify the data to be read from the user entered by the user via keyboard. The process of transforming inputs using mathematical or logical formulas to produce outputs. Output is the value displayed on the screen. 3 Output: Must identify the desired output, ie what should be displayed on the screen at the end of the program. To analyze the problem, the Input-Process-Output (IPO) chart can be used. See Figure 1.11. The steps to make an IPO analysis are: 2 Process: Steps or formulas to process input data to output. Adam took a picture of his family and sent the picture to his grandparents in the village using a smartphone. What are the inputs, processes and outputs for the smartphone? Solution: 23 Machine Translated by Google
Example 2 Example 3 A simple software asks the user to enter the year of birth. Solution: Solution: The software then determines and displays the age on the screen. Write pseudocode for a simple program that prompts for a username and displays "Hello" followed by the username. The detailed steps in a computer process are given by an algorithm. An algorithm is an idea or way of solving problems in an abstract form based on basic instructions. These basic command lines refer to the features and control structures that exist in the programming language. There are two formats of algorithm representation, namely pseudocode and flowchart. Pseudocode is not a computer programming language. Instructions are written in everyday spoken language. Each instruction is a mathematical expression, a logical expression, the use of a control structure or the use of a computer function (for example reading input). Each command is placed on a new line assigned a serial number. Steps to write pseudocode: Algorithmic Representation • Flow charts are an alternative to pseudocode using graphic symbols to represent the instructions of a solution. 3 Process data using logical or mathematical expressions. 2 Read INPUT. and has a sequence number. 5 Write the END statement. If a process cannot be described with basic computer instructions, the process is likely not suitable for a computer to execute. 1 Write the START statement. • Pseudocode is a list of computer control structures written in human spoken language 4 Display the OUTPUT. 1. START 4. END Do you know how to add value? 3. OUTPUT "HELLO" AND NAME IPO based on situation 2. INPUT NAME given. prepaid for cell phone? Build analysis Process Birth_year 3 Age = current_year - birth_year Output Age 2. Get the current year from the computer system, current_year Mind Test 1. Read the input, birth_year Computer Science Form 4 Input Pseudocode 24 Machine Translated by Google
Example 4 Instructions for processing input in the form of expressions, processing files and so on. Activity flow Write pseudocode for a simple program that asks for the user's year of birth, calculates the age, and displays the user's age. End of algorithm in flowchart. Solution: Input/Output Node name Tests conditions contained in rhombus nodes. There is one arrow in and two arrows out. One exit arrow flows to the process executed if the condition is met, while the other exit arrow flows to the process executed if it fails. Connect nodes to show process flow. Terminal is over Requirement Start terminal Process Connector Connection points to connect separate flowcharts. Function Reads input or displays output to the screen. Symbol Algorithm start in flowchart. A flowchart consists of nodes and connecting lines. Standard symbols represent each node, see Table 1.1. Each node is connected by an arrowed connecting line. Arrows indicate the flow of activity. The construction of flowcharts is not much different from pseudocode. Through flowcharts, IPOs, node symbols for all formulas, relationships between data and facts related to the problem can be identified. 3. AGE = CURRENT_YEAR - BIRTH_YEAR 1. START 4. OUTPUT AGE 2. INPUT BIRTH_YEAR 5. END Flowchart Finished Table 1.1 Flow chart standard symbols Start CHAPTER 1 PROGRAMMING 25 Machine Translated by Google
Computer Science Form 4 OUTPUT Source: creatively.com Flow charts were first introduced by Frank Gilbreth in 1921. "Hello" + name birth_year Start age INPUT name INPUT Finished age = current_year - birth_year Start When drawing a flowchart, make sure the arrows are in contact with the nodes represented by their symbols. Otherwise, the flowchart is counted as incomplete. OUTPUT Finished You should be careful when drawing a flow chart. you ? Did you know? you ? Did you know? 4 Draw a connecting line. 7 If necessary, draw process nodes or other input nodes that 3 Draw the input node. Enter details such as data collection. Steps to build a flow chart. 6 Draw a connecting line. 2 Draw a connecting line. 8 If none, draw the End terminal node. 5 Draw the process node. Enter details such as mathematical expressions. is required. 1 Draw the Start terminal node. Example 5 Example 6 Draw a flowchart for a simple program that prompts for a username and displays "Hello" followed by the username. Solution: Solution: Draw a flowchart for a simple program that asks for the user's year of birth, calculates the age, and displays the user's age. 26 Machine Translated by Google
Individual Activities c OUTPUT results. 2 Optional control structure b Data processing. 1 Sequence control structure a INPUT data. A variety of more complex computer processes can be created by combining computer statements. The three computer control structures are as follows: The sequence control structure executes the computer's command instructions one by one. The correct sequence of commands is important because different sequences can give different outputs. Each command is an algorithm statement as follows: 3 Repetition control structure 5 At the end of 2014, several states in Malaysia have experienced major flood disasters that damaged many homes, crops, livestock and so on. Among the states worst hit by floods are the states of Kelantan, Terengganu, Pahang, Perak, Sabah and Sarawak. The incident has opened the eyes of many parties to make thorough and systematic preparations in case the same disaster strikes again. As a concerned Malaysian, try to build an IPO analysis for the actions that need to be taken when a major flood occurs. Then, state the steps of the action using two representations of the algorithm, i.e. pseudocode and flowchart. Good luck! Sequence Control Structure 1.2.2 Control Structure in Programming Figure 1.12 Algorithms are easier to understand in the form of pseudocode than in computer code Pseudocode CHAPTER 1 PROGRAMMING Use Algorithms to Solve Problems goo.gl/qzP7Gn 27 Machine Translated by Google
Statement 2 For example, getting ready for school, buying food at the canteen and so on. Daily Application Start Start Finished INPUT name Finished Figure 1.13 Examples of linear sequences of algorithms in pseudocode and flowcharts Computer Science Form 4 Figure 1.14 Linear sequence of algorithms in pseudocode and flowchart for "Hello" and name The use of algorithms is applied every day in life. Everyone has actually developed their algorithm when doing any job. Mind Test OUTPUT Statement 1 Statement 3 "Hello" + name 28 Pseudocode A linear sequence of algorithms is presented as a linear sequence of statements. The syntax for linear sequences is as follows: Pseudocode Flowchart Flowchart Examples of linear sequences using pseudocode and flowcharts are as follows: Finished 4. End Start 1. Start Present it in syntax and flowchart form. Statement 3 and name Try to build a linear sequence to prepare one of your favorite food recipes. Statement 2 3. "Hello" OUTPUT Statement 1 2. INPUT name Machine Translated by Google
OUTPUT birth_year Start INPUT Mind Test Finished age = current_year - birth_year goo.gl/XCs16B Figure 1.15 Pseudocode and flowchart for age age Assignment (Assignment) statement in Java CHAPTER 1 PROGRAMMING 29 A variable is a memory space dedicated to receiving and storing data. In Mathematics subjects, especially in Algebra chapters, variables are usually given alphabetical names such as x or y. Emphasize using mathematical symbols, i.e. (=). Referring to Example 1 below, to the left of the operator is a variable such as birth_year. To the right of the operator is the value. Stack means that the value on the right is stored in the variable to the left of the stack symbol (=). Note that INPUT statements are for receiving data from the user. The user enters data through the keyboard and it will be stored in a variable. Such algorithms are said to be interactive because they involve user input. In addition to interactive input from the user, stack methods can be used to enter data into variables. However, the value of the accumulated variable is the same every time a program from such an algorithm is run. Flowchart Interactive Input Example 1: Pseudocode Stack up birth_year = 1963 (Assign the value 1963 to the birth_date variable) for all students in your class. friends and compare your answers. description of stacking, build a simple computer code for birth month 3. AGE = CURRENT_YEAR - BIRTH_YEAR 5. End Based on 2. INPUT BIRTH_YEAR 1. Start Do it together 4. OUTPUT AGE Machine Translated by Google
Computer Science Form 4 Java Arithmetic sum = number1 + number2 Input Output Finished Mind Test Input INPUT number2 OUTPUT amount goo.gl/RVLbZb Start Process Table 1.2 Arithmetic operators INPUT number1 How about drawing a chart? a method that accepts two numbers and display the total as output. flow of a program that accepts four numbers and displays the sum as output? Example 7 shows a flowchart for the program Example 2: In addition, arithmetic operators are also used in expressions that involve calculating numbers. Most of these operators are similar to mathematical operators (see Table 1.2). Exceptions are the use of the asterisk symbol (*) for multiplication and the slash symbol for division of numbers. This is because, there are no multiplication and division symbols for the standard key board. Age = 21 (Assign the value 21 to the age variable) Parentheses + Solution: Meaning Multiplication Apportionment () Operator Rejection * / Draw a flowchart for a program that accepts two numbers and displays the total as output. Addition – Example 7 30 Machine Translated by Google
DISPLAY Process Summary of operators Mind Test CHAPTER 1 PROGRAMMING Accumulate value goo.gl/5Gf2Jr INPUT radius measure_circumference = 2 * PI * radius measure_circumference, width Input Finished radius = 0 measure_circumference = 0 area = 0 Display area = PI * radius * radius OUTPUT Start "Enter radius:" Output Mind Test PI = 3.142 Example 8 Pay attention! In the input node, the commonly used words are read, input or get. In the output node, the commonly used words are display, print, write, output or report. Note that in process nodes, arithmetic operations such as addition, subtraction, multiplication and division are used in expressions. Arithmetic results are assigned to variables through the '=' symbol. Analysis of the use of words for the input, output and process nodes above is shown in the following example. Draw a flowchart for a program that accepts the size of a circle's radius and determines the circumference of the circle's area. and determine the content Based on Example 8, present the given program in pseudocode form. solid for the cylinder. for a program that accepts the radius size for a cylinder Draw a flowchart 31 Machine Translated by Google
6 SOCSO is a Social Security Organization under the Ministry of Human Resources to look after the social welfare of workers in Malaysia. SOCSO contributions require a monthly deduction from the employee's salary. Computer Science Form 4 Sequence Control The calculation formula is as follows: Have you ever received a wage? In this activity, you are required to create a computer software that can calculate the gross income and net income of employees in a local company. The software requires the input of work start time, work end time, hourly wages and SOCSO deductions. Gross income = total hours worked x hourly wages Net income = gross income - SOCSO deduction Optional Control Structure Optional control structures give computer software the ability to make decisions based on conditions that the programmer has specified. This structure allows other instructions of the computer to be executed in different problem situations. A common feature is a condition that determines one of two branches is chosen. Each branch contains a different sequence of computer instructions. If one sequence is already selected, the other sequence will be ignored. Some problems require decisions. A decision should be made after evaluating the conditions. Different results require different follow-up actions. For example, if it's dark, take a shirt off the hanger. If it's still sunny, hang your clothes on a hanger. 1 Do an IPO analysis. 2 Propose a solution to the above problem using pseudocode and a flow chart based on knowledge of sequence control structures. Individual work 32 Did you know? you ? Machine Translated by Google
Start Statement 1 Requirement? Table 1.3 Arithmetic operators goo.gl/r2r5Re Mind Test True Figure 1.16 Example pseudocode and flowchart for an optional control structure CHAPTER 1 PROGRAMMING False Statement2 Finished Equality, relational and conditional operators Meaning Equal to > < The user enters the input for the price of the item. Greater than or equal to Not the same as == (a) price Solution: Smaller than > = (b) price > 100 Less than or equal to Greater than ! = (a) Suggest a variable name. Operator <= (b) Write a logical expression to test whether the input exceeds RM100. To generate logical expressions, relational operators can be used. In the previous example, the '>' operator is used to test if the value in the price variable is higher than the tested value, which is 100. The relational operator compares the value in the variable to the tested value. The result of the test is a "True" or "False" value. Table 1.3 shows the frequently used relational operators. Pseudocode Generate conditions Flowchart Conditions used in optional control structures are logical expressions. A logical expression will evaluate the data to produce a result of "True" (True) or "False" (False). STATEMENT BLOCK 1 IF CONDITION_TRUE BEGIN_IF STATEMENT BLOCK 2 END_IF_NOT IF_NOT BEGIN_IF_NOT Example 9 Based on Example 9, write a logical expression to test whether your input is smaller than your friend's or vice versa. END_IF You buy a plate of nasi lemak, a piece of roti canai and a bowl of curry noodles during break time at the canteen. Your friend bought two plates of nasi lemak, two pieces of roti canai and a bowl of curry noodles. 33 Machine Translated by Google
Example 11 Example 10 (a) Identify the variable. (c) Write a logical expression to test the value in the variable. (b) 17 (b) Identify the value being tested. The user enters the age into the computer application. Test whether the age has reached the minimum age of 17 years. Solution: (a) age Solution: (c) age > = 17 or age > 16 Write a pseudocode to judge whether it is dark or not. Users are required to answer either "True" or "False" when asked if it is dark. If it's "True" for it's already dark, display "Take clothes off hanger." and "Save in basket.". If not, display "Hanging clothes". Pseudocode for Optional Control Structures The user enters the height in the computer application. Test whether the minimum height is 150 cm. IF_NOT BEGIN_IF_NOT STATEMENT BLOCK 1 Based on Example 10, write a logical expression to test the value in a variable for the following situation: NO and END_IF_NONE. IF CONDITION_TRUE BEGIN_IF Note that there are two blocks in the pseudocode of the optional control structure. The first block contains a block of statements that will be executed if the condition returns the value "True". The word IF followed by the condition is tested. Statement blocks must be between BEGIN_ END_IF_NOT The other block contains a statement block that will be executed if the condition from the first block fails to give the value "True", ie "False". "False" statement block must be between BEGIN_IF_ IF and END_IF. STATEMENT BLOCK 2 END_IF 3. INPUT the answer with the value "True" or "False" for existing infrastructure in response to security threats. Computer 2. Display "It's getting dark: True or False?" Computer Science Form 4 designing patches Career Science 1. START Mind Test A computer network architect builds the master plan of a communications data network and 34 Machine Translated by Google
eyes Write pseudocode to test whether the player is wearing glasses or not. The football association at SMK Gemilang is looking for new football players. The condition placed on new football players must not wear glasses Flowchart for Optional Control Structure Statement 1.1 2. Display "Enter applicant's age:" END_IF_NOT 5. END True IF_NOT BEGIN_IF_NOT END_IF Finished Mind Test OUTPUT "Take all the clothes off the hanger." END_IF Statement 1.2 4. IF age > 16 BEGIN_IF Start Statement 2.1 5. END 3. INPUT age END_IF_NOT Requirement? OUTPUT "Hang the clothes on the hanger." 1. START False OUTPUT "You are not old enough." CHAPTER 1 PROGRAMMING IF_NOT BEGIN_IF_NOT OUTPUT "Keep all clothes in basket." OUTPUT "You can request a license." Statement 2.2 4. IF It's_already_dark? BEGIN_IF Example 12 Write pseudocode for the optional control structure block to test whether the user's age has reached the minimum age of 17 years. If the user's age is 17 years or above, display that the applicant can apply to sit the driver's license test. Show that the applicant is underage if the condition test fails. Solution: The two arrows out are the results for "True" and "False". The "True" arrow is selected when the conditions in the node produce both "True" and "False" results. Each arrow leads to a different block of statements. This means that follow-up actions are different and depend on the results of the condition test. In a flow chart, a condition node, is represented by the geometric shape of a rhombus. There is one arrow in and two arrows out. The incoming arrow brings the data to be evaluated by the condition in the conditions node. The evaluation result is either "True" or "False". 35 Machine Translated by Google
Example 13 Draw a flow chart to judge whether the day is dark or not. Users are required to answer either "True" or "False" when asked if it is dark. If it's "True" for it's already dark, display "Take clothes off hanger." and "Save in basket.". If not, display "Hanging clothes". Solution: 36 "Take all the clothes off the hangers." True Finished Start answer = Computer Science Form 4 OUTPUT answer "Keep all the clothes in the basket." False State True or False:" OUTPUT INPUT "Hang the clothes on the hanger." DISPLAY "True" ? "It's dark already? OUTPUT Machine Translated by Google
Draw a flow chart for the program that determines the age of the applicant and determines whether or not the applicant can apply for a driver's license. Minimum age is 17 years. Solution: Example 14 37 DISPLAY "Enter age OUTPUT False Start CHAPTER 1 PROGRAMMING OUTPUT INPUT age Finished license." age > 16 ? applicant:" "You can ask True "You're not old enough." Machine Translated by Google
7 AEEEEEE This activity can be done in class. Setup: Computer Science Form 4 Optional Controls 38 2 The teacher will write the following game rules on the board: 4 The teacher will ask students to write their answers on A4 paper. 3 The teacher put all 10 ping pong balls into a cloth sack. Sample answer: Each answer has six alphabet combinations of A and E as follows. approximately A4. 2 The ping pong balls are given an alphabet each from 1 to 10. 3 Start the activity. The teacher will take the ball from the sack and show it to the class. The teacher will write the answers on the teacher's A4 paper. The removed ball will not be put back into the sack. 6 At the end of the activity, the teacher shows his answers to the students and asks the students to count the number of correct answers. 1 Each student is asked to take out a blank piece of paper Note: The even number test is to use modulo %. Modulo % finds the remainder of dividing a number by 2. An even number gives a remainder of zero. Odd numbers give a remainder of one. 1 The teacher prepares 10 ping pong balls. 5 The teacher will repeat steps 3 and 4 6 times. Class activities: Teamwork OUTPUT "E" IF_NOT BEGIN_IF_NOT END_IF_NOT IF NUMBER_BALLS % 2 == 0 BEGIN_IF END_IF OUTPUT "A" Machine Translated by Google
Try to imagine a student running around a circle and continuously making a circle. Pseudocode The condition is placed after the keyword UNTIL. Unlike the optional control, the repeating control uses the result of the "True" condition to repeat the instructions in the statement block. If the result of the condition is "False", then the statement block will be ignored. The syntax of the repeat control structure is as follows: A repetition control structure repeats the instructions of a computer command in blocks. Repetition can continue until it accepts the conditions to stop or reaches the set number. In the pseudocode, notice that the condition is also used as in the option control to determine the next action. Flowchart This is the case in the flow chart, see figure 1.15. A condition node in the repetition control structure determines whether a block of statements should be repeated. If the result is "True", the arrow points Statement blocks are the statements between the keyword BEGIN_ END_WHILE WHILE CONDITION BEGIN_WHILE STATEMENT BLOCKS Repetition Control Structure Requirement? goo.gl/9zXfhs Statement Block Start Repetition statements False CHAPTER 1 PROGRAMMING Finished True WHILE and END_WHILE. 39 Machine Translated by Google
OUTPUT "I am happy to come to school today." 4. End Career Science True For example, students who wake up every morning at 6:00 am and get ready for school. This is repeated from Monday to Friday. Expert data designers work with very large data sets. This work is also related to statistical calculations. Data designer experts will design algorithms and data analysis software in a specific environment. Computer False Daily Application This just doesn't happen again if there is an interruption. For example, the student had a fever on Thursday. 2. counter = 0 Condition node If we look at everyday life, it is found that repetition control structures also occur in our lives. 3. WHILE counter < 5 BEGIN_WHILE numerator = numerator + 1 Requirement? repetition Computer Science Form 4 Statement Block 1. Start Start Finished So, there will be no repetition in his life control on Friday of the week. END_WHILE Control Figure 1.17 A condition node in an iteration control structure. Example 15 The notable difference is that the direction of the arrow for the "True" result is reversed so that repetition can be performed if necessary. In the diagram above, note the difference in flowchart design between the repeat control structure and the optional control structure. That is why this structure is called a repetition control structure. to the statement block and then back to the condition node to be tested again. If the result is "False", the exit arrow will leave all statement blocks and condition nodes. Write pseudocode for an application that will print the text "I'm happy to come to school today." 5 times. Solution: 40 Machine Translated by Google
counter < 5 ? Draw a flowchart for an application that will print the text "I am happy to come to school today," 5 times. a circle of 20 rounds without stopping for the purpose of strengthening stamina. Based on 41 Start Solution: OUTPUT Finished They have been instructed CHAPTER 1 PROGRAMMING Example 16 Diana, Ai Lee and Nathan are practicing on the school field to participate in the 100 meter race. by Cikgu Hashim to run inside True numerator = numerator + 1 False counter = 0 "I'm glad to come to school today." Mind Test In this situation, build an appropriate flow chart. Machine Translated by Google