1 / 57

Flowchart

Flowchart. Basic. 1 Tom 20000 2000 18000 2 Mary 25000 2500 22500 3 Klien 30000 3000 27000 … … … … . INPUT: id, name, sal. Basic. START. INPUT id, name, sal. tax = sal * .1 net = sal - tax. PRINT id, name, sal, tax, net. END. Heading. ID NAME SAL ARY TAX NET

Download Presentation

Flowchart

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Flowchart

  2. Basic 1 Tom 20000 2000 18000 2 Mary 25000 2500 22500 3 Klien 30000 3000 27000 … … … … ... INPUT: id, name, sal

  3. Basic START INPUT id, name, sal tax = sal * .1 net = sal - tax PRINT id, name, sal, tax, net END

  4. Heading ID NAME SALARY TAX NET ------------------------------------------------------------------------ 1 Tom 20000 2000 18000 2 Mary 25000 2500 22500 3 Klien 30000 3000 27000

  5. START Heading PRINT ‘ID NAME SAL…’ ‘-----------’ INPUT id, name, sal tax = sal * .1 net = sal - tax PRINT id, name, sal, tax, net END

  6. START Heading PRINT heading INPUT id, name, sal tax = sal * .1 net = sal - tax PRINT id, name, sal, tax, net END

  7. User can change TAX RATE START 1 2 INPUT id, name, sal 3 INPUT trate tax = sal * .1 net = sal - tax 4 PRINT id, name, sal, tax, net 5 END

  8. User can change TAX RATE START INPUT trate 1 INPUT id, name, sal tax = sal * trate net = sal - tax PRINT id, name, sal, tax, net END INPUT: id, name, sal, trate

  9. How to get out from the loop? START INPUT id, name, sal tax = sal * .1 net = sal - tax PRINT id, name, sal, tax, net END

  10. How to get out from the loop? START 1 2 n y id = 0 ? INPUT id, name, sal D U M M Y 3 tax = sal * .1 net = sal - tax is the answer. 4 PRINT id, name, sal, tax, net END 5

  11. How to get out from the loop? START INPUT id, name, sal 3 y id = 0 ? n tax = sal * .1 net = sal - tax END PRINT id, name, sal, tax, net

  12. Iteration • DO WHILE LOOP • จะทำการทดสอบ เพื่อออกจาก loop ต้นสุด • เงื่อนไขที่จะออกจาก loop จะต้องเป็น เท็จ (False) Condition test False True . . .

  13. Iteration • DO UNTIL LOOP • จะทำการทดสอบ เพื่อออกจาก loop ท้ายสุด • เงื่อนไขที่จะออกจาก loop จะต้องเป็น จริง (True) . . . Condition test True False

  14. How to get out from the loop? START n id <> 0 ? DOWHILE y INPUT id, name, sal END tax = sal * .1 net = sal - tax PRINT id, name, sal, tax, net Condition PASS Position PASS Logic Fail

  15. START How to get out from the loop? INPUT id, name, sal DOWHILE n id <> 0 ? y tax = sal * .1 net = sal - tax END PRINT id, name, sal, tax, net Condition PASS Position PASS Logic PASS INPUT id, name, sal

  16. START How to get out from the loop? INPUT id, name, sal DOUNTIL tax = sal * .1 net = sal - tax PRINT id, name, sal, tax, net INPUT id, name, sal y id = 0 ? END n

  17. Footing 1 Tom 20000 2000 18000 2 Mary 25000 2500 22500 3 Klien 30000 3000 27000 ------------------------------------------------------------------------ Processed by: MIS department

  18. START Footing INPUT id, name, sal n id <> 0 ? y PRINT “-------------” “Processed by MIS” tax = sal * .1 net = sal - tax PRINT id, name, sal, tax, net END INPUT id, name, sal

  19. ID NAME SALARY TAX NET ---------------------------------------------------------- 1 Tom 20000 2000 18000 2 Mary 25000 2500 22500 3 Klien 30000 3000 27000 ---------------------------------------------------------- Processed by: MIS department

  20. ACCUMLATION: SUM 1 Tom 20000 2000 18000 2 Mary 25000 2500 22500 3 Klien 30000 3000 27000 ------------------------------------------------------------------------ 67500

  21. ACCUMLATION: SUM net = sal - tax tnet = tnet + net

  22. START ACCUMLATION: SUM INPUT id, name, sal 1 n id <> 0 ? 6 y 2 tax = sal * .1 net = sal - tax END 3 PRINT id, name, sal, tax, net tnet = tnet + net 4 INPUT id, name, sal PRINT tnet 5

  23. START ACCUMLATION: SUM INPUT id, name, sal n id <> 0 ? 6 y tax = sal * .1 net = sal - tax tnet = tnet + net PRINT tnet 3 tnet = tnet + net PRINT id, name, sal, tax, net END INPUT id, name, sal

  24. ACCUMLATION: SUM 1 Tom 20000 2000 18000 2 Mary 25000 2500 22500 3 Klien 30000 3000 27000 ------------------------------------------------------------------------ 75000 7500 67500

  25. START ACCUMLATION: SUM INPUT id, name, sal n id <> 0 ? y tax = sal * .1 net = sal - tax tnet = tsal - ttax tsal = tsal + sal ttax = ttax + tax PRINT id, name, sal, tax, net PRINT tsal, ttax, tnet INPUT id, name, sal END

  26. ACCUMLATION: SUM 1 Tom 20000 2000 18000 18000 2 Mary 25000 2500 22500 40500 3 Klien 30000 3000 27000 67500

  27. START ACCUMLATION: SUM INPUT id, name, sal n id <> 0 ? y tax = sal * .1 net = sal - tax END tnet = tnet + net PRINT id, name, sal, tax, net, tnet tnet INPUT id, name, sal

  28. ACCUMLATION: COUNT 1 Tom 20000 2000 18000 2 Mary 25000 2500 22500 3 Klien 30000 3000 27000 ------------------------------------------------------------------------ counts: 3

  29. START ACCUMLATION: COUNT INPUT id, name, sal 1 n id <> 0 ? 6 y 2 tax = sal * .1 net = sal - tax END 3 PRINT id, name, sal, tax, net count = count + 1 4 INPUT id, name, sal PRINT count 5

  30. ACCUMLATION: SUM Count = count + 1

  31. START ACCUMLATION: COUNT INPUT id, name, sal n id <> 0 ? y 2 6 tax = sal * .1 net = sal - tax count = count + 1 PRINT count count = count + 1 3 PRINT id, name, sal, tax, net END 4 INPUT id, name, sal 5

  32. INPUT ID NAME SALARY TAX NET ------------------------------------------------------------------------ 1 Tom 20000 2000 18000 2 Mary 25000 2500 22500 3 Klien 30000 3000 27000 ------------------------------------------------------------------------ counts: 3

  33. INPUT ID NAME SALARY TAX NET ------------------------------------------------------------------------ 1 Tom 20000 2000 18000 2 Mary 25000 2500 22500 3 Klien 30000 3000 27000 ------------------------------------------------------------------------ counts: 3 INPUT OUTPUT

  34. INPUT ID NAME SALARY TAX NET ------------------------------------------------------------------------ 1 Tom 20000 2000 18000 2 Mary 25000 2500 22500 3 Klien 30000 3000 27000 ------------------------------------------------------------------------ counts: 3 INPUT OUTPUT

  35. Iteration • DO WHILE LOOP • จะทำการทดสอบ เพื่อออกจาก loop ต้นสุด • เงื่อนไขที่จะออกจาก loop จะต้องเป็น เท็จ (False) Condition test False True . . .

  36. Iteration • DO UNTIL LOOP • จะทำการทดสอบ เพื่อออกจาก loop ท้ายสุด • เงื่อนไขที่จะออกจาก loop จะต้องเป็น จริง (True) . . . Condition test True False

  37. START INPUT id, name, sal DOWHILE n id <> 0 ? y tax = sal * .1 net = sal - tax END PRINT id, name, sal, tax, net INPUT id, name, sal

  38. START N X < 10? Y A = A + X X = X + 1

  39. Quiz • ให้นักศึกเขียน flowchart เพื่อให้ได้รายงานดังด้านล่าง ID NAME G.P.A. 101 Tom 3 102 Mary 2 103 Mike 4 Average GPA = 3

  40. Selection • DO WHILE LOOP • จะทำการทดสอบ เพื่อออกจาก loop ต้นสุด • เงื่อนไขที่จะออกจาก loop จะต้องเป็น เท็จ (False) True False Condition . . . . . .

  41. Tax rate < 10000 10% >= 10000 20% Selection ID NAME SALARY TAX NET ------------------------------------------------------------------------ 1 Tom 8000 800 7200 2 Mary 25000 5000 20000 3 Klien 30000 6000 24000

  42. START Before any Selection INPUT id, name, sal n id <> 0 ? y tax = sal * .1 net = sal - tax END PRINT id, name, sal, tax, net INPUT id, name, sal

  43. After Selection START INPUT id, name, sal n id <> 0 y y n sal < 10000 y END tax = sal * .1 tax = sal * .2 net = sal - tax PRINT id, name, sal, tax, net INPUT id, name, sal

  44. Tax rate < 10000 0% >= 10000 20% Selection ID NAME SALARY TAX NET ------------------------------------------------------------------------ 1 Tom 8000 0 7200 2 Mary 25000 5000 20000 3 Klien 30000 6000 24000

  45. START INPUT id, name, sal n id <> 0 y y n sal < 10000 y tax = 0 tax = sal * .2 net = sal - tax PRINT id, name, sal, tax, net INPUT id, name, sal A

  46. START START INPUT id, name, sal INPUT id, name, sal n n id <> 0 id <> 0 y y y n y n sal < 10000 y sal < 10000 y tax = 0 tax = sal * .2 tax = sal * .2 net = sal - tax net = sal - tax PRINT id, name, sal, tax, net PRINT id, name, sal, tax, net INPUT id, name, sal INPUT id, name, sal A B

  47. START START INPUT id, name, sal INPUT id, name, sal n n id <> 0 id <> 0 y y y n y n sal < 10000 y sal < 10000 y tax = 0 tax = sal * .2 tax = sal * .2 net = sal - tax net = sal - tax PRINT id, name, sal, tax, net PRINT id, name, sal, tax, net INPUT id, name, sal INPUT id, name, sal A B

  48. Tax rate < 10000 0% >= 10000 20% >= 30000 30% Selection ID NAME SALARY TAX NET ------------------------------------------------------------------------ 1 Tom 8000 0 7200 2 Mary 25000 5000 20000 3 Klien 30000 9000 24000

More Related