More Algorithm Design CSIS 1595: Fundamentals of Programming and Problem Solving 1.

Slides:



Advertisements
Similar presentations
Write a program step by step. Step 1: Problem definition. Given the coordinate of two points in 2-D space, compute and print their straight distance.
Advertisements

CSE 1301 Lecture 5B Conditionals & Boolean Expressions Figures from Lewis, “C# Software Solutions”, Addison Wesley Briana B. Morrison.
Fundamentals of Python: From First Programs Through Data Structures Chapter 2 Software Development, Data Types, and Expressions.
Flow Control Analysis & Design Tool: Flowcharts
Session Objectives# 24 COULD code the solution for an algorithm
Software Development Method. Assignments Due – Homework 0, Warmup Reading – Chapter 2 –
CS107 Introduction to Computer Science Loops. Instructions Pseudocode Assign values to variables using basic arithmetic operations x = 3 y = x/10 z =
Algorithms. Software Development Method 1.Specify the problem requirements 2.Analyze the problem 3.Design the algorithm to solve the problem 4.Implement.
Chapter 2: Input, Processing, and Output
Algorithms. Software Development Method 1.Specify the problem requirements 2.Analyze the problem 3.Design the algorithm to solve the problem 4.Implement.
Extra Notes for Assignment 1 – Salary Tax Run the sample program –The program executable can only be executed on CSLINUX machines (linux platform only)
Algorithms. Introduction Before writing a program: –Have a thorough understanding of the problem –Carefully plan an approach for solving it While writing.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 9 – Income Tax Calculator Application: Introducing.
1 Chapter 2 Problem Solving Techniques INTRODUCTION 2.2 PROBLEM SOLVING 2.3 USING COMPUTERS IN PROBLEM SOLVING : THE SOFTWARE DEVELOPMENT METHOD.
Review Algorithm Analysis Problem Solving Space Complexity
The Fundamentals: Algorithms, the Integers & Matrices.
1 L07SoftwareDevelopmentMethod.pptCMSC 104, Version 8/06 Software Development Method Topics l Software Development Life Cycle Reading l Section 1.4 – 1.5.
CMSC 104, Version 9/01 1 The Box Problem: Write an interactive program to compute and display the volume and surface area of a box. The program must also.
6 Steps of the Programming Process
Fundamentals of Python: First Programs
General Programming Introduction to Computing Science and Programming I.
Introduction to Algorithm Design and Documentation CSIS 1595: Fundamentals of Programming and Problem Solving 1.
CMSC 104, Version 9/011 Incremental Programming Topics Review of Incremental Programming Example of Incremental Programming Reading None.
TMF1013 : Introduction To Computing Lecture 1 : Fundamental of Computer ComputerFoudamentals.
Recursion.
Designing Programs with Branches CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Chapter 3 Developing an algorithm. Objectives To introduce methods of analysing a problem and developing a solution To develop simple algorithms using.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 9 – Income Tax Calculator Application: Introducing.
Developing an Algorithm
CMSC 1041 Algorithms II Software Development Life-Cycle.
Flowcharts.
An Introduction to Programming with C++ Sixth Edition Chapter 7 The Repetition Structure.
PROBLEM SOLVING WITH LOOPS Chapter 7. Concept of Repetition Structure Logic It is a computer task, that is used for Repeating a series of instructions.
Code Clichés and Conventions Lecture 10: Supporting Material Dr Kathryn Merrick Thursday 2 nd April, 2009.
CMSC 104: Peter Olsen, Fall 99Lecture 9:1 Algorithms III Representing Algorithms with pseudo-code.
1 Ch. 1: Software Development (Read) 5 Phases of Software Life Cycle: Problem Analysis and Specification Design Implementation (Coding) Testing, Execution.
Counter-Controlled Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Developing an Algorithm. Simple Program Design, Fourth Edition Chapter 3 2 Objectives In this chapter you will be able to: Introduce methods of analyzing.
Lecture 5: Stopping with a Sentinel. Using a Sentinel Problem Develop a class-averaging program that will process an arbitrary number of grades each time.
Conditional Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Designing While Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Introduction to Testing CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Running Totals CSIS 1595: Fundamentals of Programming and Problem Solving 1.
The Art of Programming. The process of breaking problems down into smaller, manageable parts By breaking the problem down, each part becomes more specific.
Algorithm Discovery and Design Objectives: Interpret pseudocode Write pseudocode, using the three types of operations: * sequential (steps in order written)
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Flowchart. a diagram of the sequence of movements or actions of people or things involved in a complex system or activity. a graphical representation.
Incremental Testing of Functions CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Algorithms and Pseudocode
CS 101 – Oct. 7 Solving simple problems: create algorithm Structure of solution –Sequence of steps (1,2,3….) –Sometimes we need to make a choice –Sometimes.
Testing Programs with Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
CIS 115 All Exercises Devry University (Devry) For more course tutorials visit CIS 115 All Exercises Devry University.
Selection Using IF THEN ELSE CASE Introducing Loops.
CIS 115 AID Peer Educator/cis115aid.com FOR MORE CLASSES VISIT
CIS 115 All Exercises Devry University (Devry) FOR MORE CLASSES VISIT CIS 115 All Exercises Devry University.
CIS 115 Slingshot Academy / cis115.com
Starter What does the following code do?
Algorithms IV Top-Down Design.
Algorithms II Software Development Life-Cycle.
Chapter 2: Input, Processing, and Output
How tax is calculated on your Taxable income Example Your gross income = $126,000 Your deduction = $ 6,000 Taxable income = $120,000.
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
CIS115 Education for Service-- snaptutorial.com
CIS 115 Teaching Effectively-- snaptutorial.com
Programming Right from the Start with Visual Basic .NET 1/e
Incremental Programming
MSIS 655 Advanced Business Applications Programming
Algorithm and Ambiguity
Chapter 2: Input, Processing, and Output
Presentation transcript:

More Algorithm Design CSIS 1595: Fundamentals of Programming and Problem Solving 1

Example Requirements: Write program to compute income taxes from gross income and dependents. – Tax is a tax rate (currently 20%) of deductible income. – Deductible income is gross income minus deductions. – Deductions include a standard deduction (currently $10,000) and a $3000 dependent deduction rate for each dependent.

Algorithm Design in Terms of Data What information do you need to keep track of? – Look for nouns in requirements – These will often become your variables Where will that information come from? – Input by user? – Specified in advance? – Computed from something else? If so, how?

Variables in Example tax deductible income × tax rate tax_rate Set at 20% deductible_income gross income minus deductions gross_income Input by user deductions standard deduction + dependents × dependent deduction rate standard_deduction Set at dependents Input by user dependent_deduction Set at 3000

Algorithm Design in Terms of Steps Order of steps often determined by data dependency Cannot compute variable until values it depends on is known – Assign variables with set values – Prompt user for variables they must provide – Compute remaining variables in order of dependencies

Dependencies in Example Set tax_rate, standard_deduction, and dependent_deduction_rate values Prompt user for gross_income and dependents values Compute deductions from standard_deduction, dependents, and dependent_deduction Compute taxable_income from gross_income and deductions Compute tax from taxable_income and tax_rate

Example Pseudocode

Constants Many values considered “named constants” – Do not change value during program – May change value in future versions of program (so should be easy to change in future) Define named constant at beginning of code – Convention: Use all caps to distinguish from variables TAX_RATE = 0.2 – Use named constant in program instead of value tax = taxable_income * TAX_RATE

Scaffold Testing Problem: Only output we have for testing is final tax value If not correct, error could come from any (or several) previous calculations – Computation of deductions – Computation of taxable income – Computation of tax

Scaffold Testing Solution: Print all intermediate values as they are computed – deduction – taxable_income Make sure these computed in advance for test Can comment out when finished – Do not delete, since may need in future!

Scaffold Testing