+ All Categories
Home > Technology > Penyelesaian masalah

Penyelesaian masalah

Date post: 24-Jun-2015
Category:
Upload: unit-kediaman-luar-kampus
View: 137 times
Download: 7 times
Share this document with a friend
Popular Tags:
22
PROBLEM SOLVING Problem solving involves: Analysis Algorithm or pseudo code or flow chart or combination of them.
Transcript
Page 1: Penyelesaian masalah

PROBLEM SOLVING

Problem solving involves: Analysis Algorithm or pseudo code or flow chart or

combination of them.

Page 2: Penyelesaian masalah

PROBLEMS ANALYSIS

Identify problems: Input Output Process

INPUT PROCESS OUTPUT

Page 3: Penyelesaian masalah

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.

Page 4: Penyelesaian masalah

ALGORITHM

Start1. Set sum = 0 and average = 02. Read 3 numbers: nom1, nom2, nom33. Add 3 numbers4. Calculate the average, average = (sum)/35. Print 3 numbers(nom1, nom2, nom3) and the average

End

Page 5: Penyelesaian masalah

PSEUDO CODE

Pseudo codeIs an artificial and informal language

Usually it is use English languageQuite 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.

Page 6: Penyelesaian masalah

PSEUDO CODE

STARTSET sum = 0, average = 0INPUT nom1, nom2, nom3sum = nom1 + nom2 + nom3average = sum / 3PRINT nom1, nom2, nom3PRINT average

END

Page 7: Penyelesaian masalah

FLOW CHART

Flow Chart It is represents by using geometry shapes with

connected line Use a standard symbol

Page 8: Penyelesaian masalah

FLOW CHART

TERMINALIndicates the beginning or end of an algorithm

PROCESSIndicates an input computational or data manipulation.

INPUT / OUTPUTIndicates an input or output operation

Page 9: Penyelesaian masalah

FLOW CHARTDECISIONIndicates a decision point in the algorithm

CONNECTOR Indicates an entry to or exit from another part of the flowchart

FLOW LINESUsed to connect the flowchart symbols and indicate the logic flow

LOOP Indicates the initial, final and increment values of a loop

Page 10: Penyelesaian masalah

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 .

Page 11: Penyelesaian masalah

CONTROL STRUCTURE

There are three type of control structure : Sequence Selection Repetition

Page 12: Penyelesaian masalah

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.

Page 13: Penyelesaian masalah

CONTROL STRUCTURE :

in

Process 1

Process 2

Process 3

out

Page 14: Penyelesaian masalah

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.

Page 15: Penyelesaian masalah

Anaylze :  input : name, salary

process : fee = salary * 1%

output : fee

Page 16: Penyelesaian masalah

FLOWCHART :

start

end

Input

salary

Print fee

Fee = 1% * salary

Page 17: Penyelesaian masalah

# 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; }

Page 18: Penyelesaian masalah

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.

Page 19: Penyelesaian masalah

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 StatementFormat :

if <(condition)> statement1;else statement2;

or if <(condition)> no semicolon statement1; else no semicolon statement2;

Page 20: Penyelesaian masalah

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

Page 21: Penyelesaian masalah

SELECTION CONTROL STRUCTURE -FLOWCHART

syarat

Kenyataan 1

y

t

Selection without else statement

if <(condition)> or if <(condition)> statement1 { statement1 statement2 : }

Page 22: Penyelesaian masalah

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.


Recommended