1 / 22

Problem Solving with the Sequential Logic Structure

Problem Solving with the Sequential Logic Structure. Chapter 5. Review. Recall that the: Algorithm: set of instructions telling the computer how to process a module in a solution. A flowchart: visual illustration of an algorithm. In this chapter you will learn how to:

onella
Download Presentation

Problem Solving with the Sequential Logic Structure

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. Problem Solving with the Sequential Logic Structure Chapter 5

  2. Review • Recall that the: • Algorithm: set of instructions telling the computer how to process a module in a solution. • A flowchart: visual illustration of an algorithm. • In this chapter you will learn how to: • Write an algorithm for each module in a program. • Draw a flowchart to accompany in each algorithm.

  3. Algorithm Instructions and Flowchart Symbols

  4. Algorithm Instructions and Flowchart Symbols

  5. Exit is used to end a subordinate module if there is no return value . • Return is used when the module is to be processed within an expression . average = sum ( num1 , num2) / 2

  6. Sequential Logic Structure • The most commonly used and the simplest logic structure . • all problem use the sequential structure . • most problem problems use it in conjunction with one or more of the other logic structure .

  7. Sequential Logic Structure • The form of the algorithm looks like this : module name ( list of parameters) 1. instruction 2. instruction 3. ….. … x x.End,Exit,or Return (variable )

  8. Flowchart Diagram for the Sequential Structure

  9. Example: The algorithm and flowchart to enter a name and age into computer and print it on the screen. ( ) Notice that the algorithm instructions are numbered starting with the first instruction after the name of module

  10. solution development • The problem analysis chart. • The interactivity chart . • The IPO chart . • The coupling diagram and the data dictionary . • The algorithms . • The flowcharts . • The seventh step in solving the problem is to test the solution to catch any errors in logic or calculation .

  11. Let’s work a problem…

  12. The Problem • Marry smith is looking for the bank that will give the most return on her money over the next five years. She has $2,000 to put into a savings account. • The standard equation to calculate principal plus interest at the end of a period of time is: Amount = p * (1+I/M)^(N*M) 12

  13. The Problem • Amount = p * (1+I/M)^(N*M) • p= principal ( amount of money to invest) • I = interest ( percentage rate the bank pays to the invested) • N = number of years ( time for which the principle is invested ) • M = compound interval ( the number of times per year the interest is calculated and added to the principal )

  14. PAC Tool

  15. The Interactivity (Structure) Chart

  16. IPO Chart

  17. Coupling Diagram

  18. Data Dictionary • in this problem all variables are local . • All coupling will be done through parameters .

  19. Algorithm and Flowchart for InterestControl Module

  20. Algorithm and Flowchart for Read Module

  21. Algorithm and Flowchart for Calc Module

  22. Algorithm and Flowchart for Print Module

More Related