Lecture_5.pdf - Problem Statement Chapter 5 Selection...

This preview shows page 1 - 3 out of 6 pages.

1 1 Objectives : To introduce the problem and problem solving that involves conditions (selection) To convert problem into flow chart and then into working functions. To introduce conditional (selection) statements such as if, if .. else, nested if .. else and switch case. Chapter 5: Selection Control Structure 2 Fato Cabinet is a furniture company based in Japan. This company imports raw material for cabinets from its branch in Malaysia. The branch is responsible to ensure that the material fulfil the specification before it can be shipped to Japan. One of the processes is to check defect of material. The length of defect is measured. If the length of defect is less than 30 cm than the material can be exported. Otherwise, the material is rejected. You are required to develop a structured diagram, flow chart and a program which consists of functions. Assume user will key-in the length of defect in cm. Your program should display an output of whether the material can be exported or rejected. Problem Statement : 3 Problem Solving : 1. Understanding Problem One of the processes is to check the length of defect material. If the length of defect is less than 30 cm than the material can be exported . Otherwise , the material is rejected . 2. Design Solution a. Classification of Problem b. Structured Diagram c. Flow Chart and Skeleton of Function d. Skeleton of Function and A Function in C++ 4 Input Process Output length if (length < 30) ‘A’ if (length >= 30) ‘R’ a. Classification of Problem b. Structured Diagram Input length of defect in cm Check whether defect or not Main Display result 5 readInt() check() display() End Function 1 : int main() input no input for function main length = readInt(); declare variable int length; Declare variables defect = check(length); char defect; display(defect); output return 0; process Skeleton of main program Flow chart of main program main() 6 readInt() Read panjang Return panjang Function 2 : int readInt() input no input for readInt cin >> panjang; declare variable int panjang; output return panjang; process Declare variables Skeleton of a function Flow chart of a function
Image of page 1

Subscribe to view the full document.