Академический Документы
Профессиональный Документы
Культура Документы
Abstraction
Decomposion (Susun balik satu satu)
PENAMAAN VARIABLE
PROBLEM SOLVING
1) Problem analysis / solution to a task (ubah sesuatu tugas kepada penyelesaian)
2) Design a solution
3) Implementation / build the program
4) Testing / debugging *tidak belajar di pdt.. kita akan belajar semasa di pst
5) Documentation
LOOPING :
Ada 3 perkara
a) Nilai awal
b) Syarat (condition) yang perlu disemak
c) Nilai kemaskini (updating values)
*kalau salah satu tiada atau silap letak ia akan jadu LOOPING INFINITY @ TAK LOOPING LANGSUNG
Create a program that will accept student’s mark. If the mark is greater than 40, print the message “PASS”.
Input : mark
Process : Print message “PASS” based on
mark
If an employee works more than 40 hours a week, compute his overtime pay which is half of his salary
Input : hour, salary
Process : Calculate overtime based on
hour
Output : overtime
Calculate area of circle when radius is greater than 0 and display the area.
Input : radius
Process : Calculate area based on radius
Output : area
KTM will give 30% discount of train ticket price if a person is below 20 years old, otherwise only 5% discount will be given. Calculate and print the ticket
price.
Input : age, original ticket price
Process : Calculate and print ticket price
based on age
Output : Ticket price
ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024
Convert the temperature in Fahrenheit (F) to Celsius (C) using the formula C = 5/9(F- 32)
Calculate the salary of an employee who works by hourly basis. The formula to be used is
Salary = Hours worked * Pay rate
Jamie saves RM1.50 per day. She would like to know the total amount she saved during the month of January
Harry wants a program that calculates and displays the amount he should tip a waiter at a restaurant. The program should subtract any liquor charge from
the total bill and then calculate the tip (using a percentage) on the remainder
Calculate how many liters of petrol that someone get if 1 liter is sell for RM1.90.
Management Bestari College run two classes. First class for open office which cost RM80 per student and second class for multimedia which cost RM100
per student. Registration will be taken by telephone for each student until every students registered. Calculate total fee for each class and total fees for
ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024
both classes. Every students is compulsory to take either one of the two courses provided.
11. The program will display the student name entered by user
SOALAN : JAWAPAN :
State 2 techniques to design an algorithm. Give two important differences 2 techniques are
between the two techniques. - flowchart and pseudocode.
Pseudocode an artificial, informal language (similar to english) used to develop
algorithm. While flowchart a graphical representation of an algorithm in relation to its
sequence of functions
Determine input-process-output analysis for 1(a) and 1(b) statements. a. Input : number of tiles / qtyTiles(1Mark)
a. You need 100 tiles to tile your bathroom wall. The tiles are sold in Process : to calculate number of boxes based on number of tiles (1 Mark)
boxes of 5. How many boxes will you need to buy? Output : number of boxes(1 Mark)
b. A shop buys DVDs for RM5 each. It sells them at RM11 each, or 3 b. Input : qtyDVD (1Mark)
for RM24. Calculate how much profit would they make on selling Process : Determine profit based on qtyDVD (2 Marks)
DVDs?. Output : profit (1 Mark)
a. Write a pseudocode that takes a number as input and prints its multiplication a.
table up to 10. Start
Expected Output : Read num
Enter no: 8 i =1
8x1=8 Repeat while i <=10 (i is less than or equal to 10)
8 x 2 = 16 ans = num x i
8 x 3 = 24 Display num + “ x” + i + “=” + ans + “\n”
… i++
8 x 10 = 80 End repeat
b. Draw a flowchart for question no 2(a). End
b.
t is the time (in seconds) it takes the ball to reach the ground. g is the force
of gravity (9.81 meters per sec2). [2 marks]
(b). Prepare a problem analysis that will read two integer numbers and an Input: integer code
integer code from the user. The value of the integer code should be 1,2 or Process: To determine sum or difference or product of two numbers or display
3. The table below specifies the process to be taken based on the integer error
code. The program displays the computed results to the screen. Output: sum or difference or product or “Display error”
(f). Abu is assigned to calculate the sum of all numbers and the total
number that are divisible by three between 15 and 60 (inclusive). Display
the numbers of digit and the sum of these numbers as the output. Design a
solution by using pseudocode. [7 marks]