Penyelesaian masalah


Published on

Published in: Technology, Education
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Penyelesaian masalah

  1. 1. PROBLEM SOLVING  Problem solving involves:  Analysis  Algorithm or pseudo code or flow chart or combination of them.
  2. 2. PROBLEMS ANALYSIS  Identify problems:  Input  Output  Process INPUT PROCESS OUTPUT
  3. 3. ALGORITHM  Algorithm  Any computing problem can be done by executing a series of actions in a specific order.  A procedure for solving a problem in terms of the actions to be executed and the order in which these actions are to be executed is called an algorithm.  Is a logical solution that is inline with our daily language or mother tongue language.
  4. 4. ALGORITHM Start 1. Set sum = 0 and average = 0 2. Read 3 numbers: nom1, nom2, nom3 3. Add 3 numbers 4. Calculate the average, average = (sum)/3 5. Print 3 numbers(nom1, nom2, nom3) and the average End
  5. 5. PSEUDO CODE  Pseudo code Is an artificial and informal language Usually it is use English language Quite similar to programming language The purpose of pseudo code is to make humans who do not understand computer programming can easily understand the flow of the problem solving.
  6. 6. PSEUDO CODE START SET sum = 0, average = 0 INPUT nom1, nom2, nom3 sum = nom1 + nom2 + nom3 average = sum / 3 PRINT nom1, nom2, nom3 PRINT average END
  7. 7. FLOW CHART  Flow Chart  It is represents by using geometry shapes with connected line  Use a standard symbol
  8. 8. FLOW CHART TERMINAL Indicates the beginning or end of an algorithm PROCESS Indicates an input computational or data manipulation. INPUT / OUTPUT Indicates an input or output operation
  9. 9. FLOW CHART DECISION Indicates a decision point in the algorithm CONNECTOR Indicates an entry to or exit from another part of the flowchart FLOW LINES Used to connect the flowchart symbols and indicate the logic flow LOOP Indicates the initial, final and increment values of a loop
  10. 10. CONTROL STRUCTURE •It’s a technique in producing program logic which is simple and easy to understand •.It show the problem solution whether it’s a jujukan, selection or repetition control structure or the combination of two or three control structure. •Every programmer should analyze the problem to indentify the suitable control structure that must use .
  11. 11. CONTROL STRUCTURE  There are three type of control structure :  Sequence  Selection  Repetition
  12. 12. SEQUENCE CONTROL STRUCTURE  Sequence control structure used when a problem is solved sequentially from start to end. Every instruction is perform once only. It used to solve problems that easy. This solution does not involve any condition and there is no repetition of instructions.
  13. 13. CONTROL STRUCTURE : in Process 1 Process 2 Process 3 out
  14. 14.  Example 1: Kebajikan FTMK mengenakan yuran sebanyak 1% dari jumlah gaji setiap ahli untuk tabung kebajikannya. Lukiskan cartalir dan tuliskan aturcara untuk mencetak nama dan yuran yang diterima dari seorang ahlinya.
  15. 15. Anaylze : input : name, salary process : fee = salary * 1% output : fee
  16. 16. FLOWCHART : start end Input salary Print fee Fee = 1% * salary
  17. 17. # include <iostream.h> // Program to calculate and display club fee main () { // Initialization of variables char name [15]; // staff name float salary =0, fee=0; // salary and fee // Data entry section cout << “please enter staff name"; cin >> name; cout << “please enter salary "; cin >> gaji; // Processing section fee = salary *.01; // Printing Section cout << “Staff name “<<name<<endl; cout << "n The club fee is RM"<<fee; // end of programme return 0; }
  18. 18. EXAMPLE 2  Assume N number of students have to take MTS1033 course in UPSI and each student is required to buy C++ book with a price of RMX. The publisher will get 10% profit for each book that is sold. Write a program to calculate and print the profit that earned by the publisher.
  19. 19. CONTROL STRUCTURE - SELECTION  Selection control structure is used when the execution of instructions are depend on the result of a decision/selection that the program must make if ..else Statement Format : if <(condition)> statement1; else statement2; or if <(condition)> no semicolon statement1; else no semicolon statement2;
  20. 20. SELECTION CONTROL STRUCTURE -FLOWCHART condition Statement 2 statement 1 y n If the value of condition is true, then statement1 will be executed, otherwise statement2 will be executed
  21. 21. SELECTION CONTROL STRUCTURE -FLOWCHART syarat Kenyataan 1 y t Selection without else statement if <(condition)> or if <(condition)> statement1 { statement1 statement2 : }
  22. 22. CONTROL STRUCTURE -SELECTION  Cost of printing price for coloured poster is RM2000 for the first 500 pieces and RM1000 for black and white poster. For each piece above then 500, the cost is RM2 for coloured and RM1.50for the black an white. Write a pseudo code and a programme to calculate payment that need to be paid by a customer.