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

110
Chapter Chapter 1 1 Software Development and Software Development and Analysis of the Problem Analysis of the Problem Mr.Warawut Khangkhan Twitter: http://twitter.com/awarawut Facebook: http://www.facebook.com/AjWarawut E-Mail: [email protected] E-Mail: [email protected] Mobile: 083-0698-410

Upload: warawut

Post on 02-Nov-2014

635 views

Category:

Education


3 download

DESCRIPTION

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

TRANSCRIPT

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

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: [email protected]: [email protected]

Mobile: 083-0698-410

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

ContentsContents

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

� Inputs

�Outputs

� Processing

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

��� '��-'�

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

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

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

�� �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

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

�� �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

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

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

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

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

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

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

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

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

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

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

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

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

&�����;!�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

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

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

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

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

������"� ��� ���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

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

�)+#����� ��� ���!���/%�&���������������)+#����� ��� ���!���/%�&��������������� ������ ��� ������ ��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

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

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

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

1. ……………..

2. ……………..

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

END

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Pseudo CodePseudo Code

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

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

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

�������������� �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

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

�������������� �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

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

�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

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

� ������ ��#����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

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

��� '� � ������ ��#����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

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

� ������ ��#����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

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

��� '� � ������ ��#����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

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

� ������ ��#����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

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

� ������ ��#����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

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

��� '� � ������ ��#����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

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

� ������ ��#����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

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

��� '� � ������ ��#����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

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

� ������ ��#����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

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

� ������ ��#����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

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

���#���������)��.��>�� ���#���������)��.��>�� 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

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

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

statement a

statement b

statement c

::

:

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

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

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

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

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

�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

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

��� '� ���. �����"������ '� ���. �����"���(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

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

��� '� ���. �����"������ '� ���. �����"���(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

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

��� '� ���. �����"������ '� ���. �����"���(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

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

��� '� ���. �����"������ '� ���. �����"���(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

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

��� '� ���. �����"������ '� ���. �����"���(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

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

��� '� ���. �����"������ '� ���. �����"���(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

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

��� '� ���. �����"������ '� ���. �����"���(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

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

�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

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

�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

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

��� '���� '� 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

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

��� '���� '� 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

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

��� '���� '� 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

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

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

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

���� -��� 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

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

�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

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

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

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

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

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

Mr.Warawut Khangkhan 72

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

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

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

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

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

Mr.Warawut Khangkhan 74

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

#�����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�'��)-��%� )���+�

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

#�����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!�"����'� ��� ���)

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

#�����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

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

#�����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�;�)

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

����&������� �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

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

����&������� �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

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

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

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

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

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

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

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

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

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

��� '� ������ �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

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

��� '� ������ �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

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

��� '� ������ �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

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

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

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

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

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

��� '� ������ �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

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

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

salary

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

tax = salary * 0.1

Stop

print salary, tax

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

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

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

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

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

������ �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

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

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

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

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

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

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

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

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

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

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

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

������ �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

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

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

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

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

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

������ �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

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

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

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

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

������ �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

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

������ �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

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

������ �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

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

��� '� ������ �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

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

��� '� ������ �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

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

Start

I = 0

I <= 4N

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

Print I

I = I + 1

Stop

Y

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

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

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

������ �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

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

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

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

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

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

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