Вы находитесь на странице: 1из 40

COMPUTER SCIENCE : DC024

Dalam soalan keluarkan OUTPUT dan tentukan PROCESS dan INPUT


COMPUTETION THINGKING :

 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

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


IPO PSEUDOCODE FLOWCHART
Input / Process / Output  A written statement of an algorithm using a  A set standard shaped boxes that are connected by
semiformal language with limited flow lines to represent an algorithm.
vocabulary.

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


Calculate volume of cuboid

Calculate total price for 7 items bought by user

Calculate volume of sphere

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


Calculate total mark for computer science subject. It will be count based on average of 3 quizzes and total of two tests.

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

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


Output : Message “PASS”

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

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


Calculate area of circle when radius is greater than 0.0 and display the area. If not, display “Radius can’t be a negative number”.
Input : radius
Process : Calculate and print area or
print message “Invalid radius” based on
radius.
Output : Area or message “Invalid
radius”

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

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


Alif lives in a state that charges a 5% sales tax. He wants a program that displays the amount of sales tax due on a purchase

Jamie saves RM1.50 per day. She would like to know the total amount she saved during the month of January

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


Henry belongs to a CD club. Last year, he bought all of his CDs from the club at RM8 per CD. He wants to know how much he saved last year by buying the
CDs through the club rather than through a music store

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

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


The manager of the Lake View Hotel wants a program that calculate and displays a guest total bill. Each guest pays a room charge that is based on a per-
night rate. For examples, if the per-night rate is RM100 and the guest stays two nights, the room charges is RM200. Customer also may incur a one-time
room service charge.

Calculate how many liters of petrol that someone get if 1 liter is sell for RM1.90.

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


Given the Zoo Melaka entrance ticket rate as below:
Price for adults : RM15

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


Price for children : RM6
Allow user to key in the number of family members based on the criteria above, and the program will calculate total paid by the visitors.

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.

Print “Welcome to KMK” 10 times.

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


Create a program to calculate the total of 5 numbers entered by user and print the total

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


Answer all questions:Do IPO, pseudocode and flow chart.

11. The program will display the student name entered by user

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


12. The program will calculate the multiplication of three numbers.

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


13. The program will process sale price of a book after 10% discount and 6% GST.

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


14. Calculate net salary for a worker based on working hour rate of rm3 per hour. 5% will be deducted for an insurance payment.

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


15. The program will calculate liter of petrol needed according to Ringgit Malaysia entered by user. (RM2.50 = 1 liter)

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


16. The program will calculate hotel room payment. (Charge per night: RM 180 for deluxe room, RM 250 for Superior room)

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


1. Final Marks are calculate from average marks of 3 quizzes and total of two tests. Display the final mark.

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


2. A factory worker is paid base rm2.50 per hour. Calculate monthly net salary after deduct 10% for kwsp from total salary.

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


1. Calculate the volume of cuboid.

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


2. User input two numbers. The program will calculate and display four mathematical calculations - addition, subtraction, multiplication and modulus based
on number entered

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


3. Calculate and display the price of a book after discount 15%

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


4. Calculate total price for hotel room used by the guest. Your calculation must include number of day stay and 6% GST.

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


5. Write pseudocode to swap value in memory 1 into memory 2. Given memory 1="rambutan", memory 2="durian".

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


1.Ahmad wants to create a program that determines the total area of a piece of land where length and width are given

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


2.Calculate and print the volume of sphere.

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


3.Convert a measurement in milimeter(mm) to meter(m) and print the result.

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


4.A government tax of 6% and service tax of 10% will be added to price of a set of meal bought at McK. Calculate the total price that Abu has to pay for a set
of meal.

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


5.Read three numbers and print their sum and average

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


6.Calculate and display the overtime pay received by an employee. Overtime rate is RM 5 per hour.

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


7.Afiq is a sales person for a company that sell used computers. The price for brand A is RM550 per unit while brand tiles B cost RM1100 per unit. The
company will pay her 11% commission for the total sales where total sale will calculated based on the number of computer sold for both brands.

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


8.Ah Hong plans to install floor tiles for his guest area spaces which are rectangular in shape. The price per square feet of floor tiles will be determined after
Hong chooses the suitable tiles. Calculate and display the area of Hong's guest area space and the total cost of needed to be paid by him

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


CONTOH SOALAN DAN JAWAPAN

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.

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


(a). Programming is the process of taking an algorithm and encoding it into 1 (a)(i) a step by step method of solving a problem OR a step by step instructions
a notation, a programming language so that it can be executed by a that will transform the input into the output
computer.
(i). Describe an algorithm. [2 marks] 1(a) (ii) Pseudocode
(ii). State two (2) representations of an algorithm. [2 marks] Flowchart
ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024
1. (a). Prepare a problem analysis that calculates how far up you are in Input:force of gravity
feet based on the number of seconds it takes for a dropped ball to reach Process:To calculate height of falling object
the ground. A Google search of calculating height by timing falling object Output:height in meter
discovers this formula: height (meters) = ½gt2

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”

Input: costofitem, quantity


Process: To calculate finalcost based on costofitem, quantity
Output:finalcost

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


Input: code
Process: To repeatedly determine category of items and calculate number of
cards, sweets, stationaries and toys based on code
Output: number of cards, sweets, stationaries and toys

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024


(e). The surface area of a cylinder is calculated by using this formula 2𝜋𝑟2 +
2πrh, where, r is the radius, π is constant value 3.142 and h is height. Draw
a flowchart for a program that asks for the height and radius of two
cylinders and determines which cylinder has the greater area, or the same.
[8 marks]

(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]

ALIFFUDDIN FITRI BIN MOHAMAD _ 010 274 2293 _ DC024

Вам также может понравиться