Download presentation
Presentation is loading. Please wait.
Published byEdith Shaw Modified over 9 years ago
1
Introduction to Algorithm Design and Documentation CSIS 1595: Fundamentals of Programming and Problem Solving 1
2
Stages of Program Development Analysis: What must the program do? Design: How should the program work? Implementation: Coding the program Testing: Making sure the program works Maintenance: Upgrading to meet new requirements
3
Example Requirements: Write program to compute taxes. Taxes are computed as the tax rate (currently 20%) times taxable income. Taxable income is gross income minus total deductions. Total deductions are a standard deduction (currently $10,000) plus a dependent deduction (currently $3,000) times the number of dependents. Implementation: Very difficult to do this directly
4
Algorithms and Pseudocode Algorithm: Set of steps to solve problem – Usually pseudocode – Can use to implement code Example: Computing Celsius temperature 1.Ask user for Fahrenheit temperature 2.Compute Celsius temperature from the Fahrenheit temperature 3.Display the Celsius temperature to the user
5
Algorithm Design Often involves refining for more detail – Additional steps – Detail about computation Example: Computing Celsius temperature 1.Ask user for Fahrenheit temperature 1.Convert to floating point value 2.Compute Celsius temperature from Fahrenheit temperature using formula (Fahrehneit – 32)/1.8 3.Display the Celsius temperature to the user
6
Readability Code must be easily understood by people – Other programmers who maintain your code – Yourself in future Descriptive variable names White space – Spaces between words on same line – Blank lines between sections of code Comments (documentation)
7
Comments Comments: Text in program meant to explain how it works – What each section does – How it does it (if not obvious) – Often includes header that briefly describes what program does as a whole Syntax in Python: # comment – Anything after the # is ignored by the Python interpreter
8
Comments Can create directly from pseudocode – Often write comments before writing code
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.