1 / 6

The Five Steps

The Five Steps. Understanding the problem Do a small example by hand Write an algorithm for solving the problem Translate the algorithm into a programming language (like C) Test the program. C Program Contents. Comments: in beginning and throughout program

robbiea
Download Presentation

The Five Steps

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 Five Steps • Understanding the problem • Do a small example by hand • Write an algorithm for solving the problem • Translate the algorithm into a programming language (like C) • Test the program

  2. C Program Contents • Comments: in beginning and throughout program • Header statements: include C libraries • Functions (main, library, your functions): • Header: function name and arguments main() • Body • Declarations • Statements: assignments, expressions, calling other functions, generating output

  3. Testing a program • Remove syntax errors: Look at compiler comments where errors occurred and check program around these lines • Remove link errors: again check comments where errors occurred • Run time errors: • Semantic errors (check function arguments) • Logic errors: manual trace, check precedence of operators, add debugging code to check variables

  4. Good Programming Practices • Careful algorithm development • Modular programming • Incremental testing • Program tracing • Documenting code

  5. Stock Portfolio Task Write a program to analyze a stock portfolio consisting of some number of different stocks we own. For each stock we have information on how many shares we own, how much we paid for each share, and how much each share is worth now. Stock prices are expressed as a whole dollar amount and a fraction (e.g. 1/2, 1/4, 1/8, etc.). We would like to compute how our portfolio is worth and how much profit we have made if we liquidated it today.

  6. Bottom up ApproachAdd features Go back to five step design process and make modifications • Read input data from terminal • Compute profit or loss from number of shares owned and price bought and price sold • Read in several stock data information and compute profit of loss • Compute cumulative gains or losses

More Related