Amalan Kejuruteraan Sem 3 2013/2014 Problem Solving Tool Amalan Kejuruteraan Sem 3 2013/2014
Structure Chart/Hierarchy Chart Structure Chart shows : the functional flow through your program. how you are going to break your program into logical steps, each step will be a separate module. the interaction between all the parts(modules) of your program.
Flooring cost Get UserInfo Calculate Cost Print Report Calc Linoleum Calc Carpeting Calc Kitchen Calc Bathroom Calc Bedroom Calc Living Areas Structure chart for calculating square footage.
Pseudo code Precise algorithmic description of program logic Its purpose is to describe, in precise algorithm detail, what the program being design is to do. Requires the defining the steps to accomplish the task in sufficient detail so that they can be converted into a computer program.
Pseudocode for Calculate Bathrooms Algorithm Calculate Cost 1.0 prompt user and read linoleum price 2.0 prompt user and read number of bathrooms 3.0 set total bath area and baths processed to zero 4.0 while (bath processed < number of bathrooms) 4.1 prompt user and read bath length and width 4.2 total bath area = total bath area + bath length * bath width 4.3 add 1 to bath processed 5.0 end while 6.0 bath cost = total bath area * linoleum price 7.0 return bath cost End Algorithm calculate Bathrooms
Flowchart Uses standardized symbols to show the steps the computer needs to take to accomplish the programs goal.
Basic Symbols Represent Various Operation Direction Preparation Terminal – beginning / end Process Decision Input / Output Connector Sub-function
Flowchart for the whole program Start Get User Info Calculate Cost Print Report Start
Calculate Cost Read (linoPrice) Read (numBath) bthArea zero bathProc zero 1
1 bathProc < numBath READ (bthLngth,bthWdth) bthArea bthArea + linoCost RETURN No Yes bthArea * linoPrice
Decision Structure If student’s grade is greater than or equal to 60 Pseudocode If student’s grade is greater than or equal to 60 Print “Passed” Else Print “Failed”
Repetition Structure While product is less than or equal to 1000 Pseudocode While product is less than or equal to 1000 Multiply product by two