1 / 21

The Need for Program Design

The Need for Program Design. A program must be designed before it is written. You should not go to the keyboard and start typing instructions into the program before designing it. STAIR problem çözme süreci. S tate the problem (Problemi tanımlayın)

Télécharger la présentation

The Need for Program Design

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. The Need for Program Design • A program must be designed before it is written. You should not go to the keyboard and start typing instructions into the program before designing it.

  2. STAIR problem çözmesüreci • State the problem (Problemi tanımlayın) • Identify the tools available for solving the problem (Problemi çözmek için mevcut araçları belirleyin) • Write an algorithm (Bir algoritma yazın) • Implement the solution (Çözümü gerçekleştirin) • Refine the solution (Çözümü sadeleştirin)

  3. Algoritma = Pseudocode

  4. Write the algorithm to make a peanut butter and jelly sandwich 1. Put the bread, peanut butter, jelly, knife, and plate onto the workspace. 2. Place two slices of bread on the plate. 3. Using the knife, spread peanut butter on one slice. 4. If you want jelly, using the knife, spread jelly on the other slice. 5. Slap the two slices together, sticky side in. 6. Repeat steps 2 through 5 for each sandwich needed. 7. Eat the sandwiches.

  5. Bir Algoritmanın Özellikleri • Has input, performs a process, and gives output. • Must be clear and unambiguous (belirsiz). • Must correctly solve the problem. • Can be followed with paper and pencil. • Must execute in a finite number of steps.

  6. Flowchart = Akış Diyagramı • It is said that a picture is worth a thousand words, and the flowchart provides a pictorial representation of program logic. • Flowcharts are made up of industry-standard symbols.

  7. Dikdörtgen: İşlem Baklava: Karar Paralel Kenar: Giriş ya da Çıkış Daire: Bağlantı Ok: Akış yönü Oval: Başlama ya da Durma noktası Akış Diyagramı Sembolleri ve Fonksiyonları

  8. Bir arkadaşınızı telefonla aramak için izlenebilecek bir akış diyagramı

  9. The Rules of Flowcharting • Rule #1— Use standard flowcharting symbols. • Rule #2— The flowchart's logic should generally flow from the top of the page to the bottom of the page, and from left to right. • Rule #3— The decision symbol is the only symbol that can have more than one exit point, and it always has two. • Rule #4— A decision symbol should always ask a yes or no question. • Rule #5— Instructions inside the symbols should be clear English descriptions, not computerese or programming language statements.

  10. Yağlı Ballı Ekmek Akış Diyagramı 1. Put the bread, peanut butter, jelly, knife, and plate onto the workspace. 2. Place two slices of bread on the plate. 3. Using the knife, spread peanut butter on one slice. 4. If you want jelly, using the knife, spread jelly on the other slice. 5. Slap the two slices together, sticky side in. 6. Repeat steps 2 through 5 for each sandwich needed. 7. Eat the sandwiches.

  11. Karmaşık Problemler • Bir evliliği gerçekleştirmek için gerekli algoritmanın yazılması • Bir bordro programına ait algoritmanın yazılması • Bir bankamatiğe ait algoritmanın yazılması

  12. Karmaşık Problemlerin Çözümünde Algoritma Süreci: Problemin Parçalara Ayrıştırılması • To attack more complex problems, top-down design is used. • Intop-down design, the overall problem is broken into the main tasks (usually input, process, output),and then each of these tasks is broken down into subtasks until a simple solution can be seen for eachsubtask.

  13. Hierarchy Charts (Organizasyon Şeması) • Usually hierarchy charts are used as a help in top-down design. Hierarchy charts differ fromflowcharts in that they indicate what should be done, not how the job will be accomplished.

  14. Problemin Parçalara Ayrıştırılması • the process of taking the overall problem and breaking it down more and more until you finalize all the details. • One of the keys to top-down design is that it forces you to put off the details until later. Top-down design forces you to think in terms of the overall problem for as long as possible. Top-down design keeps you focused.

  15. Parçalara Ayırma Süreci • Determine the overall goal. • Break that goal into two, three, four, or more detailed parts. Too many more parts make you leave out things. • Put off the details as long as possible. Repeat step 2 until you cannot reasonably break down the problem any further.

  16. Bir Evlilik Töreninin Parçalara Ayrıştırılması

  17. Bir Bordro Programının Parçalara Ayrıştırılması

  18. Bir bankamatikteki görevlerin parçalara ayrıştırılması

  19. The flowchart for a simple ATM machine

  20. The algorithm for a simple ATM machine 1. Get the password from the user. 2. If the password is not valid, construct an error message and skip to step 6. 3. Get the inputs. 3.1. Get the transaction type (deposit or withdrawal), and the amount from the user. 3.2. Get the current balance from the bank. 4. If the transaction type is deposit, add the amount to the current balance. 5. If the transaction type is withdrawal, check the current balance. 5.1. If amount is greater than the current balance, construct an error message and skip to step 6. 5.2. If amount is equal to or less than the current balance, subtract the amount from the current balance. 6. Output the error message or the cash, and the current balance. 7. Ask the user whether to repeat steps 3 through 6 for another transaction.

More Related