การพัฒนาซอฟต์แวร์และวิเคราะห์การแก้ปัญหา...

Post on 02-Nov-2014

635 Views

Category:

Education

3 Downloads

Preview:

Click to see full reader

DESCRIPTION

การพัฒนาซอฟต์แวร์และวิเคราะห์การแ้ก้ปัญหา

TRANSCRIPT

Chapter Chapter 1 1

Software Development and Software Development and Analysis of the ProblemAnalysis of the Problem

Mr.Warawut Khangkhan

Twitter: http://twitter.com/awarawut

Facebook: http://www.facebook.com/AjWarawutE-Mail: awarawut@hotmail.comE-Mail: awarawut@hotmail.com

Mobile: 083-0698-410

ContentsContents

� ��������������� ������ ��� ����� ����������������� ������������������������ ���������������������������� ���������������������������� ������ � ��� ���!��������������"��#�

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 2

��������������� ������ ����������������� ������ ��

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 3

��������������� ������ ����������������� ������ ��

� ��$�������������������%��&����$�������"����&��'

� ()%���#��&��������"��������#����*������!��� #"������������������� ������ ��� �(��� #"������������������� ������ ��� �(��(�%�� )���+� �-'� ���./ � ������ �� ��./ �"���&-������� ��� (�%������������ )�������&-�&����%"������� ��%��

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 4

����� ��������������������� ����������������(STEPS IN PROGRAM DEVELOPMENT)(STEPS IN PROGRAM DEVELOPMENT)(STEPS IN PROGRAM DEVELOPMENT)(STEPS IN PROGRAM DEVELOPMENT)

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 5

����� ��������������������� ����������������

1. �"���%����� (Define the Problem)2. �'��� ��� � %���������������� (Outline the Solution)

3. ����� ��� ���!� (Develop and Algorithm)3. ����� ��� ���!� (Develop and Algorithm)4. ���(# ����01��� � ��� ���!� (Test the Algorithm for Correctness)

5. ��� �������� (Programming)6. �%# ������� (Testing)7. (�%�"�� �#�����"��)���2�������� (Document and Maintain the Program)

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 6

11. . �"���%����� �"���%����� (Define the Problem)(Define the Problem)

� Inputs

�Outputs

� Processing

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 7

22. . �'��� ��� � %�����������������'��� ��� � %����������������(Outline the Solution)(Outline the Solution)� �����&����$�-����� ' 3 ��. ��$�������$�� � (���(���"���%�����)

� ����'��� ��� � %�����������6�������'�3 ���� %�� ◦ ����� ����������7�#'������3◦ ����� ����������7�#'������3

◦ #'������� ����/6%��������� ' (Subtask)◦ #'������#���������71�&-���◦ ���#�����/&-����)� �-'� �����8�"� ��. ����"���%����. �◦ ������������#���� ��� ��%

◦ ������������ (Logic)

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 8

33. . ����� ��� ���!������ ��� ���!�(Develop and Algorithm)(Develop and Algorithm)� ����� ���/&-� ��� �"�%�����"��� ������6%��9������������ �� ��� ���!���/ ���

� 81�%���% (Pseudo Code) ��$������� ��� ���!���./ &-����6��������� ������ ����./ &-����6��������� ������ ��

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 9

44. . ���(# ����01��� � ��� ���!����(# ����01��� � ��� ���!�(Test the Algorithm for Correctness)(Test the Algorithm for Correctness)� ��$������ ���/#"������/#)%� ���(# ��� ������ ��� ���!� ���������� �������"��� �1��%# ����6�������7�&���'������� �

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 10

55. . ��� ����������� ��������(Programming)(Programming)� �"� ��� ���!���/6%������ �� '�#�1�+��������%�� ������ �������� (-)%�"�#�/)

� ��. �&-�*�2���%�#1 (High Language) ��./ ��� �������� �-'� C, PASCAL ��$������� �������� �-'� C, PASCAL ��$����

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 11

66. . �%# ��������%# �������(Testing)(Testing)� �"��� �1��: �����6���./ �%# ����./ �����������/6%���� ��!���'�01��� ��. 6�'

� ������(# ◦ �1��-)%�"�#�/ (Syntax Errors)◦ �1��-)%�"�#�/ (Syntax Errors)◦ ������� (Logic Errors)

� �� �1��%# �� ����������'���� �6������'��#0�����+����#*����%�� �

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 12

77. . (�%�"�� �#�����"��)���2��������(�%�"�� �#�����"��)���2��������(Document and Maintain the Program)(Document and Maintain the Program)� ���(�%�"�� �#������ �������(��� (�%�"������'����� �����"���%�����(�0!�!��� �#)%��� �. ����%# 7������

� � �#������ �������(����� %�� ◦ � �#��*� � � (External Document) �-'� 7����#��� ◦ � �#��*� � � (External Document) �-'� 7����#��� ��� ���!���/&-����6������ ���7�� ����%# �� �1�

◦ � �#��*� &� (Internal Document) �. -)%�"�#�/&��������

� ���"��)���2��������(����/ ��� ����%1����������)�������

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 13

����������������������������������������������

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 14

����������������������������������������������

�������/�&�-�������("������ 1' 2 ����*� �. � �������/������� ���/��'� �&������������ �-'� ���������� �;�#��� 8!/��#1�� ����<��+=��./ �6���/��'� ���/(�����������'� ���/(���������

� �������/6�'������� ���'� �������&������������ �-'� �������/�� &-������1�#!��!���% �� &-�%)� ����(&������%#��&(���6�

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 15

������������������������������������������������������

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 16

������������������������������������������������������

1. �������������7������2. ��������������� �1�3. �������������������������������. �������

������7��� �1�������7��� �1�

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 17

11. . �������������7�������������������7������

� ��(��+��'��(� ��� ����"�� �6� ����/�"�� ����"�� 1'&��1���� �1�&% ��$������� ��. ��� ��2� ��. �1�� ./�3 ����� ����"�6��"� �6��' 6� (7��������/6%��� 6��"���+�' ��. 6�' ��$����)(7��������/6%��� 6��"���+�' ��. 6�' ��$����)

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 18

22. . ��������������� �1���������������� �1�

� ��(��+��'����� �1� �6�����/���/ ��� &����(��"���+��7������ �% ���2+�� �� �1��� 1' 3 ���2+� %����◦ �� �1���/�(� ��"���%��&���% ��◦ �� �1���/�(� ��"���%��&���% ��

◦ �� �1���/�(� �6�'6%� ��% ��◦ �� �1���/��$��.��>����(�������������7�����3

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 19

�� �1���/�(� ��"���%��&���% ���� �1���/�(� ��"���%��&���% ��

��� '��-'�

�"���%&�� a = 20 b = 15 c = 5("���������� � 10 ���� -./ �1���� �. ���%� (����� ��� �*�+��� -./ �1���� �. ���%� (����� ��� �*�+�

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 20

�� �1���/�(� �6�'6%� ��% ���� �1���/�(� �6�'6%� ��% ��

� ����% � � �% ' ����2+����'��/�� �������/ ������. ���+��0!�� �1����?%���� ��� '��-'�� !����������"����#������"� ��/��. ("���������� � n ��� !����������"����#������"� ��/��. ("���������� � n ��� �������� �$������%&$�'#�����"��� ��/��. �� �1���$��������'������/71�&-����� ���

� ��� !������(� 2 !����'��'*+����,������ ��/��. �� �1���$����("������@������/71�&-����� ��� 2 ���

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 21

�� �1���/��$��.��>����(�������������7�����3�� �1���/��$��.��>����(�������������7�����3

� �(� �6�'("���$��� ���. -����� ��� '��-'�� �!���-���.����%*������%"� �/"'��&$�'#�'*+�� �$���%���%"��� ����,������ ��/��. �� �1���/(��� &-�&�����"���+�.����/%���'����� 6%���'�"���+�.����/%���'����� 6%���'������ ����% ��� (Base)������ ����% ��� (Height) 8!/��%(���)������A��

��>�������� ½ ��. 0.5 8!/��$�����+����% (Constant)

(��� ��&-��1+�'����>�� ���#1 ��$�6����#1������"���+�.����/#������/ ���/�'� = ½ x base x height

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 22

33. . ����������������������������������������������������������

� ����� ������$������ ���/#"������/#)%&������� ����������./ ���������% &-�� ������ �� ������� �#%����#�����������'��� �1���/6%�(���������������7������ ������������������ �1� &�� 1'&��1������"���+�������������������� �1� &�� 1'&��1������"���+���+��;�#��� ��. �./ �6���/� ������ ���1�(����'�����

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 23

��� '� ������������������������������ '� ���������������������������&�����;!�2���� ������������������(�������@��������*�������� *��� ���;!�2�

� ���������&������ - 7����� ������ ����������� �$� - �(� � �-�%�(��'���������� ��������*�������� *�� �����A�����(!����/��� �� �1� 1' ���*�������� *�� �����A�����(!����/��� �� �1� 1' 2 ("���� �. ��������*�� ����������� *��

� ������������������������� - �(� � �-�%�(��'��� � ���������*������� *�������� (!(�6%��������� %����

�������� = ��������*�� + �������� *��

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 24

��� '� ������������������������������ '� ���������������������������

&�����;!�2���� ���������"���+���.����/� #������/ �1. ���������&������ - �.����/� #������/ �2. ����������� �$� - �(� �6�'6%� �-�%�(��'��"�

'�6� ��'�� �����$�#1���+��;�#����.��>��&������ '�6� ��'�� �����$�#1���+��;�#����.��>��&�������.����/#������/ ��. �� �1�#1���#� �' � �. area = ½ x base x height

3. ������������������������� - �� ���&-�#1��-�%�(���'� � %�����(!�� �"���+���#1��

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 25

������"� ��� ���0�������������������"� ��� ���0��������������!��*� �!��*� �!��*� �!��*�

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 26

������"� ��� ���0��������������!��*� ������"� ��� ���0��������������!��*�

Algorithm

� �. ��)'�� ����� ���. �<��+=���/(��"���6�#1'�����������6%�

� �. ����� ����� 8!/(�&-� ��� �'���3 �����"� '�6� �% (�� �. ����� ����� 8!/(�&-� ��� �'���3 �����"� '�6� �% (����� %�� -)%�"�%���$�������$�� ���/-�%�(� ������������'���./ 6%��9����01��� �������� �(��� �@(�6%�7��������/01��� ����� ���

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 27

�)+#����� ��� ���!���/%�&���������������)+#����� ��� ���!���/%�&��������������� ������ ��� ������ ��1. ��� ���!��� 6�'�"���� '�������������&('� 2. ��� ���!��� ������01��� &�7��������/&-����6������

&���+��'�33. ����������. ����� ���/��)6��&� ��� ���!��� ��3. ����������. ����� ���/��)6��&� ��� ���!��� ��

������� '� ��� � �' ���%"���������./ ������7�&�� ������ ��6%�

4. ��� ���!��� ��()%#���#)%

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 28

�1�������� ��1�������� �AlgorithmAlgorithm

Algorithm <-./ � ��� ���!�>

1. ……………..

2. ……………..

3. …………….3. …………….

END

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 29

Example AlgorithmExample Algorithm

��� ���0�����������%�0%*!���( �$�

1. (�%���� �����/�!/#"���@(�1�2. �����"�#� �%&���%. %3. �"�����/�!/#"���@(�1�&#'�&�-��3. �"�����/�!/#"���@(�1�&#'�&�-��4. A��8 �����./ ��)�&�-��5. �"���"���/����%. %���&�-��6. �?%C�7. � �����+ 3 ����

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 30

Example Algorithm (Cont.)Example Algorithm (Cont.)

Algorithm ����01. A�%��"�����0&����/���./ �(�%C)D�����;2%����� �'�3

�2. 7#��-��1����0 1 C��' ��"���!/0�2. 7#��-��1����0 1 C��' ��"���!/0�3. �"�F #1'-)��"��-��1�-@%�"�����#� �%&����/�4. A�%��"����&��#� �%5. &-�7���)'�3 ��. 7��-��������/#� �%�-@%&�����6. (

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 31

Example Algorithm (Cont.)Example Algorithm (Cont.)

Algorithm ������. #��01. ����0 (�"� ��� ���!��������0��&-�)2. �"�F ��"�()'���"� ����. #��0 3. �:� ����0��0%�� �������$����� &����/����0��03. �:� ����0��0%�� �������$����� &����/����0��04. ��' &�����#�������!/ 5. �-@%%�� 7���)'�3 ��/#� �%6. (

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 32

Example Algorithm (Cont.)Example Algorithm (Cont.)

Algorithm ���-���F1. ���� �0�� ���F2. &#'���F#"���@(�1� 2 -� �3. &#'���� 2 -� �

&#'��"���� 2 �� �3. &#'���� 2 -� �4. &#'��"���� 2 �� �5. &#'��"��� � ¾ � ����6. ��&���������7. (

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 33

Example Algorithm (Cont.)Example Algorithm (Cont.)

��� ���0�'����'#����.% ��/������������

turn on calculatorclear calculatorrepeat the following instructionskey in baht amountkey in baht amountkey in decimal point (.)key in satang amountpress addition(+) key

until all prices have been enteredwrite down total priceturn off calculator

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 34

������"� ��� ���0��������������!��*� ������"� ��� ���0��������������!��*�

(Cont.)(Cont.)�����"��#� ��� ���!���/�� ��� 2 ���� �. � ���#("�� (Pseudo Code)� 7��� (Flowchart)

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 35

Pseudo CodePseudo Code

� �"���&-���� ��� ���!�� ��������� ��#����0�"� ��� ���!���/�"��#� &��1��81�%���%6���� ���$�-)%�"�#�/*�2��������6%�����������

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 36

�������������� �81�%���%�������������� �81�%���%

1. 0� �"���. ���� ��"�#�/ (Statement) &����� � 1'&��1��� *�2� ��H2 '�'�

2. &���!/����% &����� ����� ��"�#�/��� �"�#�/�%� �3. ���&-� ' ����&����$����� -����./ � ��"��A���3. ���&-� ' ����&����$����� -����./ � ��"��A���(Keywords) 6%� '�-�%�(� ���0!(�%���#��� ������)�&����$�#�%#'�� 8�/�������"�%���'��(��"�&�� '��'�

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 37

�������������� �81�%���%�������������� �81�%���% (Cont.)(Cont.)

4. ��'������ ��"�#�/&����� ��"�%�(�����'� �% ����� ���������%� �������� ����%� ���'�����

5. ��)'�� ���� ��"�#�/�'�3 �((�%�����)'�����%�� ���&��1��� ��%1� ��'�� �"���%-./ ��%1����'�����&��1��� ��%1� ��'�� �"���%-./ ��%1����'�����%�� ��./ &��#����0��� �&-�����%1�����6%�

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 38

�9��������.��>�� �9��������.��>�� 66 ������� � ������ ��������� � ������ ��(Six Basic Computer Operations)(Six Basic Computer Operations)1. � ������ ��#����0���� �1�6%�2. � ������ ��#����0�#%7������6%�3. � ������ ��#����0�"���+6%�4. � ������ ��#����0�"���%�'�������6%�4. � ������ ��#����0�"���%�'�������6%�5. � ������ ��#����0���� ��� �����. �����"���

6%�6. � ������ ��#����0�"���8�"�3 6%�

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 39

� ������ ��#����0���� �1�6%�� ������ ��#����0���� �1�6%�

� )���+����� �1� ( ���)�) �-'� �� ������� �� � ��% ��. ���� �1�(����� '��6F���� �1��#./ (�%��@�� �1�6%� �-'� ��� '���� �1�(��%�#�� ��� '���� �1�(����� ��. ������� �1�7'������:��� � ��% ��$����������� �1�7'������:��� � ��% ��$����

� &���� '���� �1�(�&-��"���� � read ��� get ��./ &-�&������� �81�%���%◦ read &-���./ ���������. '����� ��%(��6F���� �1�◦ get &-�#"�������� �1�(����:��� � ��%

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 40

��� '� � ������ ��#����0���� �1�6%���� '� � ������ ��#����0���� �1�6%�

read studentName

get systemDate

read number1, number2

get taxCodeget taxCode

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 41

� ������ ��#����0�#%7������6%�� ������ ��#����0�#%7������6%�

� ����#%7������(�&-��"���� � print, write, put, output ��. display◦ print &-�#"�������#'7������ ������./ �����◦ write &-�#"�������#'� ����)���./ ��@���!��&�6F��◦ write &-�#"�������#'� ����)���./ ��@���!��&�6F��◦ put, output ��. display (�&-�#"�������#'� ����)� �6��#%7���( *��

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 42

��� '� � ������ ��#����0�#%7������6%���� '� � ������ ��#����0�#%7������6%�

print “Program Completed”

write customer record to master file

put name, address and postcode

output totalTaxoutput totalTax

display “End of data”

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 43

� ������ ��#����0�#%7������6%� � ������ ��#����0�#%7������6%� (Cont.)(Cont.)

� �"�#�/ prompt ��/&-�#"�����#%�� �����' ���/(�&-��"�#�/ get, ��./ (�6%�#����0#./ #������ �� 1#�8 ��6%� '�#�1�+� �/�!��

promt for studentMark

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 44

promt for studentMarkget studentMark

� ������ ��#����0�"���+6%�� ������ ��#����0�"���+6%�

� #�����2+���/&-�&�����"���+◦ #�����2+� + &-��������� (add)◦ #�����2+� – &-�������� (subtract)◦ #�����2+� * &-��������1+ (multiply)◦ #�����2+� * &-��������1+ (multiply)◦ #�����2+� / &-���������� (divide)◦ #�����2+� ( ) &-�������./ ��� ���@��?%/�?%

� �"���� ���/&-�&�����"���+(�&-��"��'� compute ���calculate

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 45

��� '� � ������ ��#����0�"���+6%���� '� � ������ ��#����0�"���+6%�

divide totalMarks by studentCount

salesTax costPrice * 0.10

compute C = (F – 32) * 5 / 9

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 46

� ������ ��#����0�"���%�'�������6%�� ������ ��#����0�"���%�'�������6%�

#����0�"�6%� 3 �1�� %����1. &-��"���� � initialize ��. �"��'� set ��./ �"���%�'�

���/����&����������2. &-�#�����2+����./ ��� = ��. ���./ ��� � ��./ 2. &-�#�����2+����./ ��� = ��. ���./ ��� � ��./

�"���%�'�&����������3. &-��"���� � store &����(�%��@�� �1�&����������

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 47

��� '� � ������ ��#����0�"���%�'���������� '� � ������ ��#����0�"���%�'�������6%�6%�initialize totalPrice to zero

set studentCount to 0

totalPrice = costPrice + salesTax

totalPrice� costPrice + salesTaxtotalPrice� costPrice + salesTax

store customerId in lastCustomerID

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 48

� ������ ��#����0���� ��� �����. ����� ������ ��#����0���� ��� �����. �����"���6%��"���6%�� &-��"� if…then…else ���(%�� end if �#�

if employeeStatus is partTime thenadd 1 to partTimeCount

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 49

elseadd 1 to fullTimeCount

end if

� ������ ��#����0�"���8�"�3 6%�� ������ ��#����0�"���8�"�3 6%�

� &-��"� dowhile…enddo ��. repeat…until

dowhile file_flag <> “eof”read student record

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 50

read student recordprint studentName, address to reportadd 1 to studentTotal

enddo

eof – End Of File

���#���������)��.��>�� ���#���������)��.��>�� 33 �1���1��(The Three Basic Control Structures)(The Three Basic Control Structures)� ���� �"�%� (Sequence)� ���. �����"��� (Selection)� ��"���8�"� (Repetition)

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 51

�1������ �"�%��1������ �"�%�(Sequence(Sequence Format)Format)

statement a

statement b

statement c

::

:

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 52

��� '� ���� �"�%���� '� ���� �"�%�

add 1 to pageCount

print heading line1

print heading line2

set lineCount to zeroset lineCount to zero

read customer record

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 53

�1�����. �����"����1�����. �����"���(Selection Format)(Selection Format)if condition p is true then

statement(s) in true case

else

statement(s) in false casestatement(s) in false case

end if

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 54

��� '� ���. �����"������ '� ���. �����"���(Simple IF Statement)(Simple IF Statement)if accountBalance < 300000 then

serviceCharge = 5.00

else

serviceCharge = 2.00serviceCharge = 2.00

end if

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 55

��� '� ���. �����"������ '� ���. �����"���(Null False Branch)(Null False Branch)if employeeStatus = partTime then

add 1 to partTimeCount

end if

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 56

��� '� ���. �����"������ '� ���. �����"���(Combined IF Statement (Combined IF Statement 11))if employeeStatus = partTime

and employeeGender = female then

add 1 to partTimeCount

end ifend if

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 57

��� '� ���. �����"������ '� ���. �����"���(Combined IF Statement (Combined IF Statement 22))if (recordCode = “23” or updateCode= delete)

and accountBalance = zero then

delete customer recorddelete customer record

end if

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 58

��� '� ���. �����"������ '� ���. �����"���(Combined IF Statement (Combined IF Statement 33))if not (recordCode = “23”

and updateCode = delete) then

update customer record

end ifend if

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 59

��� '� ���. �����"������ '� ���. �����"���(Nested IF Statement (Nested IF Statement 11))if recordCode = “A” then

increment counter_A

else

if recordCode = “B” then

increment counter_B

elseelse

if recordCode = “C” then

increment counter_C

else

increment errorCounter

end if

end if

end if

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 60

��� '� ���. �����"������ '� ���. �����"���(Nested IF Statement (Nested IF Statement 22))if employeeStatus = partTime then

if employeeGender = female then

if employeeAge > 30 then

add 1 to matureFemaleEmployee

else

add 1 to youngFemaleEmployeeadd 1 to youngFemaleEmployee

end if

else

add 1 to maleEmployee

end if

else

add 1 to fullTimeEmployee

end if

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 61

�1����"���8�"� �1����"���8�"� (Repetition Format)(Repetition Format)dowhile

dowhile condition p is true

statement blockstatement block

enddo

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 62

�1����"���8�"� �1����"���8�"� (Repetition Format)(Repetition Format) (Cont.)(Cont.)repeat…until

repeat

statementstatement

statement

:

:

until condition is true

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 63

��� '���� '� dowhiledowhile looploop 11

set studentTotal to zero

dowhile studentTatal < 50

read student record

print studentName, address to print studentName, address to report

add 1 to studentTotal

enddo

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 64

��� '���� '� dowhiledowhile looploop 22

Process Student_record

set studentCount to zero

read student record

dowhile studentNumber not equal 999dowhile studentNumber not equal 999

write student record

increment studentCount

read student record

enddo

print studentCount

endMr.Warawut Khangkhan

Chapter 1 Software Development and Analysis of the Problem 65

��� '���� '� repeat … until looprepeat … until loop

Process Student_record

set studentCount to zero

repeat

read student recordread student record

if studentNumber not equal 999

write student record

increment studentCount

end if

until studentNumber = 99

print studentCount

end Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 66

7��� 7��� (Flowchart)(Flowchart)

� ��$����./ �. �����!/&�����#%����"���� � ������ �� ���1����/'� �' ��������&(� )�����/�6�

� 7���6�' !%��%��6� ���+�*�2�&%*�2���!/ ��'(�&-�� 7���6�' !%��%��6� ���+�*�2�&%*�2���!/ ��'(�&-�#�����2+���$�#./ �������'�71���� ����71� '��

� ������ �7���������� (��� ;!�2�0!#�����2+���/&-������������"�#�����2+����'����������� �����$�-)%�"�#�/��./ �#%����"���� �������

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 67

���� -��� 7������� -��� 7���

1. �"�&��� ��@��1��� ��6%������% �% &-�����6�'���

2. ������ �7�����$�#��� #����0�"�6���� ��"�#�/6%��)�*�2��)�*�2�

3. #����0���(# �� 7�%���%� �������6%� '���%��@�

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 68

�1�������� �7����1�������� �7���

������ �7���#����0�' ���$� 2 ����*�&��'3 �. � 7����� (System Flowchart)� 7���������� (Program Flowchart)

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 69

7�����7����� (System Flowchart)(System Flowchart)

� &-��#%����� �����"�� *� &�������!/3 �% ��'��0!�� �1��'�3 ��/���/ ��� �����% �-'� � �#���.� ����. �6� ��#%)��/&-��. �6� &-���'� ����("�����*�&% (��� #'7'��6� ���'� ��&% �����������*�&% (��� #'7'��6� ���'� ��&% �������������7��������#%7������ �% (���'�� '�����3 6�'#����0�"������ ���$��������6%�

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 70

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 71

Mr.Warawut Khangkhan 72

7����������7���������� (Program Flowchart)(Program Flowchart)

� (��#%0!����� �� �"�#�/��/&-�&�������� ������� �1� ���������7� ����#%�� �1� �����(���� ��'� 7������� ��������

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 73

Mr.Warawut Khangkhan 74

#�����2+�� 7���#�����2+�� 7���

Terminal &������� �����"����"��'� START ��. STOP 6��*� &�#�����2+�%�� Manual Input ��$�#�����2+��#%�: � �1�%�� ���� �-'� �: ��� �1�����:������

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 75

%�� ���� �-'� �: ��� �1�����:������

Monitor (Output) ( *���#%7� ��$�#�����2+�&�����#%�� �1�������( � ������ ��Input/Output Data ���������#%7��� �1��% 6�'��)-��%� )���+�

#�����2+�� 7���#�����2+�� 7��� (Cont.)(Cont.)

Process �#%�"�#�/���������7�&���������-'� ����"���+ ������/�-�%�'� ��$����Decision ��$�#�����2+� 8!/(�6%�7������ ���2 ��+� �. (�� (True) ��. ��@( (False) �� ���� �

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 76

2 ��+� �. (�� (True) ��. ��@( (False) �� ���� ����./ ��� �"�0�� (?) 6��*� &�#�����2+�%�� Magnetic Disk %�#����'���@� 8!/&-�&������@�� �1�Comment &-��#%�� ������� ���)� ������� �% &-��#�������)0!�"����'� ��� ���)

#�����2+�� 7���#�����2+�� 7��� (Cont.)(Cont.)

Preparation (������� �) &-�&�����"���%�'����/����� ����� ����8@��'��'�3Sobroutine processing (���������7���/�"���%6���' �) &-��������"�����/01��"���%6������ + ()%&%()%��!/&�������� �-'� ������� '

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 77

6���' �) &-��������"�����/01��"���%6������ + ()%&%()%��!/&�������� �-'� ������� ' ��$���� ��. �((��#%0!��������������7�-)%&%3 ��/���� �!��(���"�#�/("������!/Document (� �#��) �#%0!��� ���)�/� ����)��� �1�����*�� �#��&%3

#�����2+�� 7���#�����2+�� 7��� (Cont.)(Cont.)

Connector &-�#�����2+���/&-��-./ ��' ������ �������*� &������%� ���� �% ������"������ ��2���. ��� ���)����&�#�����2+�%��

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 78

#�����2+�%��

Off-Page Connector &-��-./ ��' &���+���/()%%���'�� 1'�����������

Flow Direction Lines �#%��;��� �������(��)%�� ��;������1�;�)

����&������� �7�������&������� �7���

1. &-�#�����2+�01��� ���������� ��/�"���%6��2. �����&-��1�;��#%��;�����6��� �� �1�(���

��'� ��. (��8�� 6����3. �"� ��� &� Flowchart ���#��� ����&('� ���3. �"� ��� &� Flowchart ���#��� ����&('� ���

6%�&(����4. �)� Flowchart (��� ���1�;��#%��;�����

������� �

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 79

����&������� �7�������&������� �7��� (Cont.)(Cont.)

5. #"����#�����2+���/ 1'�'�������3 6�'���� �#���-./ �0!��� ��'���&-�#�����2+�()%�-./ ��' ���

6. ���������%# ����01��� � ����"���(��Flowchart �' �(��"�6���� ���$��������Flowchart �' �(��"�6���� ���$��������

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 80

�1�������� �7����1�������� �7���

� ���� �"�%� (Sequence)� ���. �����"��� (Selection)� ��"���8�"� (Repetition)

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 81

������ ����� �"�%������� ����� �"�%�

� ��$�7�����/�#%�"�#�/����"�%�����"���(�����'� ��� ����"�%��' ���� &�����"�%��' ���� &����������7�(�������7������;��� �1�;� �% 6�'����� � ������. �����%#��&(

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 82

��� '� ������ �7������� �"�%���� '� ������ �7������� �"�%���� �7����"���+���.����/� #������/ ���� �7����"���+���.����/� #������/ �Algorithm �!���-���.����%*������%"�

1. ���'�(����:��������@6����/������ base ���height

2. �"���+���.����/#������/ � (area) (��#1��2. �"���+���.����/#������/ � (area) (��#1��area = 0.5 * base * height

3. �#%7��.����/#������/ � (area)

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 83

��� '� ������ �7������� �"�%���� '� ������ �7������� �"�%���� �7����"���+���.����/� #������/ ���� �7����"���+���.����/� #������/ �Algorithm �!���-���.����%*������%"�

get base, height

compute area = 0.5 * base * height

display areadisplay area

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 84

��� '� ������ �7������� �"�%���� '� ������ �7������� �"�%���� �7����"���+���.����/� #������/ ���� �7����"���+���.����/� #������/ �

Start

base, height

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 85

area = 0.5 * base * height

Stop

area

��� '� ������ �7������� �"�%���� '� ������ �7������� �"�%�

�"���%&��71�&-��: ��'�����%. � (salary) �������./ (��"�����"���+ *�2� (tax) 10% &���% �������� ���(�������'� salary �� tax

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 86

��� '� ������ �7������� �"�%���� '� ������ �7������� �"�%�

Algorithm ������'� salary �� tax1. ���'�����%. � (Salary)2. �"���+*�2�(��#���� tax = salary * 0.13. �#%����%. � ���*�2�3. �#%����%. � ���*�2�

---------------------------------

get salary

compute tax = salary * 0.1

display salary, tax

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 87

��� '� ������ �7������� �"�%���� '� ������ �7������� �"�%�Start

salary

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 88

tax = salary * 0.1

Stop

print salary, tax

Workshop: Workshop: ������ �7������� �"�%������� �7������� �"�%�

� (��� �7���������'�� #���� Y = 2X * 2� (��� �7�������"�-./ ������#�)�

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 89

������ �7����������. �����"��������� �7����������. �����"���

� 7���-��%���������"�������"�%�(�����'����. �7��������"�%� ��'���/�#'�������%#��&(��./ &��#����0��. ��"������7������� �./ �6� 8!/��%#��&(��./ &��#����0��. ��"������7������� �./ �6� 8!/7��������/6%����'���$�(�� (True) ��. ��@( (False) ��'����� ��� �-'� &������"��������� .%� )'�����!��

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 90

������ �7����������. �����"��� ������ �7����������. �����"��� (Cont.)(Cont.)

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 91

Workshop: Workshop: ������ �7������������ �7����������. �����"�������. �����"���(��� �7��� �������"������ �� 0����"������������'� 100 &���#%�� �����'� J��"����������'� 100K ��'0����"������� ��'���. ��'��� 100 &���#%�� �����'� J��"������� ��'� 100K �% �"���%&����������� �1�(��J��"������� ��'� 100K �% �"���%&����������� �1�(����:����������#%7�7'����( *��

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 92

Workshop: Workshop: ������ �7������������ �7����������. �����"�������. �����"���(��� �7��� ������� ��� ��"������ �� ���� 2 �� � 8!/��"�����(��� 6�'��'���� 0����"������ �� ������ ����������'���"������� ���/# &���#%�� �����'� J�� ������ ����������'��� ������ ���/# K ��'0���� ������ ���/�� ����������'��� ������ ���/# K ��'0���� ������ ���/# ����"����������'��� ���� &���#%�� �����'� J�� ������ ���/# ������'��� ������ ����K �% �"���%&����������� �1�(����:����������#%7�7'����( *��

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 93

������ �7����������. �����"��� ������ �7����������. �����"��� (Cont.)(Cont.)� ���7�������./ �6� �#����0���./ �6�8� ��./ �6�6%�

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 94

������ �7����������. �����"��� ������ �7����������. �����"��� (Cont.)(Cont.)

Start

Stop

name, score

1

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 95

score > 0

score > 49Display �Error�

1

Display �Pass�

1

Display �Not Pass�

1

Y

NY N

Workshop: Workshop: ������ �7������������ �7����������. �����"���8� ��./ �6�����. �����"���8� ��./ �6�(��� �7��� ������� ��� ��"������ �� ���� 2 �� � 8!/��"������ �� ����#����0��'����6%� 0����"������ �� ������ ����������'���"������� ���/# &���#%�� �����'� J�� ������ ����������'��� ������ ���/# K �� �����'� J�� ������ ����������'��� ������ ���/# K ��'0���� ������ ���/# ����"����������'��� ���� &���#%�� �����'� J�� ������ ���/# ������'��� ������ ����K ���0����"������� �������# �� ���'���� &���#%�� �����'� J�� �������# ����"�������'����K�% �"���%&����������� �1�(����:����������#%7�7'����( *��

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 96

Workshop: Workshop: ������ �7������������ �7����������. �����"���8� ��./ �6�����. �����"���8� ��./ �6�� (��� �7��� �����%���%� ���;!�2� �% �"���%-'�� �����%����

80 ! 100 A

70 ! 79 B

60 ! 69 C60 ! 69 C

50 ! 59 D

0 ! 49 F

������� �1�&�����'�(����:������ �% ���'���/��$�-./ �������� #'������#%7�&���#% ���( *�����-./ , ����� ������%��/���;!�2�6%������"���2 &����������(# �����&�� 1'&�-'� 0 ! 100 ��'����� 0�������"���%&���#%�� �1� �Out of range�

97

������ �7�����"���8�"������� �7�����"���8�"�

� 7���-��%��� &-��#%����"����������"�8�"� *� &���./ �6���/�"���% 7������� �./ �6����'���$�(��(True) ��. ��@( (False) -'� &������"���� ������������#����*��#1�!��������������#����*��#1�!��

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 98

������ �7�����"���8�"� ������ �7�����"���8�"� ((�' �' ))

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 99

������ �7���������� �7�����"���8�"� �"���8�"� (Cont.)(Cont.)

N = ?I = ?

Start

N = 0I = 1

N = 55I = 11

N = ?I = 5

N = 15I = 5

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 100

Stop

I <= 10

N = N + I

I = I + 1

Display IY

N

������ �7���������� �7�����"���8�"� �"���8�"� (Cont.)(Cont.)

Start

N = 0I = 1

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 101

StopI <= 10

N = N + I

I = I + 1

Display IY N

������ �7�������(# �./ �6��' ������� �7�������(# �./ �6��' ��"���8�"��"���8�"�

� ����"���8�"�����(����/����%�� �����(��+��./ �6��' ���$� ��%���� 0���./ �6���$�(��(�����#1'���������"�8�"���/�"���% ��'0���./ �6���$���@((� �(�����������"�8�"������(�����������"�8�"������

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 102

��� '� ������ �7������� '� ������ �7�����"���8�"� �"���8�"�

Algorithm &���������� 0 0! 4 ��( *��1. �"���%������ I ���'���'��� 02. ���(# ������ I2.1 0�� I <= 4 &��2.1 0�� I <= 4 &��

� ������'� I � I = I + 1 (���/��'�&���������� I �� 1)� 6��"������ ���/ 2

2.2 0�� I > 4 &��(����"���

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 103

��� '� ������ �7������� '� ������ �7�����"���8�"� �"���8�"�

Algorithm &���������� 0 0! 4 ��( *��set i to 0dowhile i <= 4 thenprint iprint iadd 1 to i

enddo

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 104

Start

I = 0

I <= 4N

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 105

Print I

I = I + 1

Stop

Y

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 106

������ �7�������(# �./ �6������8�"������� �7�������(# �./ �6������8�"�

� ����"���8�"����� (����/�%�� �������#1'���������"����' � 1 � ����(!��(��+��./ �6� 8!/����'�(�� Do while �. ���&%��/�./ �6���$���@( ���������"�8�"�(�%"������' 6� (������/��./ &%��/���������"�8�"�(�%"������' 6� (������/��./ &%��/�./ �6����'���$�(��(! �(�����������"�8�"�

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 107

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 108

Workshop: Workshop: ������ �7�����"�8�"� ������ �7�����"�8�"�

� (��� �7������'��A��/ � ������ 1-10 �% &���#%7� ���( *�� 8!/��$��'��A��/ ��/����6%�

� (��� �7������'�7��������'��A��/ � ������ 1-10 �% &���#%7� ���( *�� 8!/��$��'�7����10 �% &���#%7� ���( *�� 8!/��$��'�7��������'��A��/ ��/����6%�

� (��� �7����"���+��'#1�� �% ��)��'#1����/�� ��� 8!/(��� 1'&�-'���' 2 – 12 ��'����� &���+���)������/�"���%&���#%�� ����7'����( *�� JError”

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 109

Homework:Homework:

1. (��� �7������&-������;����#����+� %�� ���&-�������;���� �����'���/����&-��� #���� (������/(���#����

2. (��� �7�����./ ������'��������A�������1'(��-)%2. (��� �7�����./ ������'��������A�������1'(��-)%�����������' 1 – 50

3. ���/�����(���� 2. ����"���+���'��A��/ , �'�#1#)% ����'��/"�#)% � -)%��������/&����

Mr.Warawut KhangkhanChapter 1 Software Development and Analysis of the Problem 110

top related