Page 187 - เอกสารประกอบการสอนพื้นฐานการเขียนโปรแกรมคอมพิวเตอร์
P. 187

186


                       5. การวิเคราะห์การประมวลผล (Process)
                                ยอดจัด      ค านวณจาก ราคาสินค้าลบเงินดาวน์

                                             (leasing = price – down)
                               ดอกเบี้ยจ่าย    ค านวณจาก ยอดจัดคูณอัตราดอกเบี้ยต่อปีคูณจ านวนปีที่ผ่อนช าระ
                                                       (interate = leasing * (rate / 100) * n)
                               ยอดจัดรวมดอกเบี้ยจ่าย ค านวณจาก ยอดจัดบวกดอกเบี้ยจ่าย

                                                   (total = leasing + interate)
                               ยอดผ่อนช าระต่อเดือน ค านวณจาก ยอดจัดรวมดอกเบี้ยจ่ายหาร (จ านวนปีที่ผ่อนช าระคูณ12)
                                                      (pay=total/(n*12))
                       การออกแบบโปรแกรม   ค านวณหาอัตราการผ่อนช าระค่าสินค้าต่องวด

                       Pseudo Code
                       1. start
                           do

                       2. input  price, down
                       3. leasing = price – down
                       4. print leasing
                       5. input rate, n
                       6. interate = leasing * (rate / 100) * n

                       7. total = leasing + interate
                       8. pay = total / (n*12)
                       9. print interate, total, pay

                       10. input ans
                       11. while (ans== ‘y’)
                            ถ้า ans เป็นจริง วนกลับไปท าข้อ 2
                            ถ้า ans เป็นเท็จ ท าข้อ 12.

                       12. stop
   182   183   184   185   186   187   188   189   190   191   192