1 / 15

Software Development Method for Algorithm Design

Learn the step-by-step process for developing algorithms, from problem analysis to implementation, testing, and maintenance. See examples and exercises for practical understanding.

briang
Download Presentation

Software Development Method for Algorithm 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. Algorithms

  2. Software Development Method • Specify the problem requirements • Analyze the problem • Design the algorithm to solve the problem • Implement the algorithm • Test and verify the completed program • Maintain and update the program

  3. Software Development Method • Specify the problem requirements • In this class, often done for you • Analyze the problem • Your job – what are the inputs and outputs • Design the algorithm to solve the problem • Your job – write it down and turn it in! • Implement the algorithm • Your job • Test and verify the completed program • Your job – this is the most time consuming part • Go back to step 4 if your program fails the tests • Maintain and update the program • Always assume you will reuse your code at some point

  4. Algorithms • Step-by-step procedure for solving a problem • Be as specific as possible – include all steps • Example – doing your laundry

  5. Calculate Tax on an Item • Problem • Analysis • Algorithm design • Implementation • Testing • Maintenance

  6. #A program to calculate tax and total cost for an item. #determine rate of taxation #ask user for the cost of the item #calculate the tax #calculate total cost #display the results

  7. #Name: Sami Rollins #A program to calculate tax and total cost for an item. #determine rate of taxation TAX_RATE = .0825 #ask user for the cost of the item cost = input("Enter item cost: ") #calculate the tax tax = cost*TAX_RATE #calculate total cost total = cost+tax #display the results print "Cost: ", cost print "Tax : ", tax print "Total: ", total

  8. #Name: Sami Rollins #A program to calculate tax and total cost for an item. Heading • Indicates what the program does • Comments • # to the end of the line

  9. #determine rate of taxation TAX_RATE = .0825 Variables • Sets the value of the variable TAX_RATE to be .0825

  10. #ask user for the cost of the item cost = input("Enter item cost: ") Input • Prompt the user for the cost of the item and store the response in the variable cost

  11. #calculate the tax tax = cost*TAX_RATE Calculation • Multiply the cost times the tax rate and store the result in the variable tax

  12. #calculate total cost total = cost+tax Calculation • Add the cost and the tax and store the result in the variable total

  13. #display the results print "Cost: ", cost print "Tax : ", tax print "Total: ", total Output • Display the results for the user

  14. Exercises • Write the algorithm for a program that takes as input the number of miles a car has traveled and the number of gallons of gas the car has consumed and calculates the number of miles the car can travel on one gallon of gas.

  15. Exercises • Write the program for the algorithm you just generated using the tax program as a template.

More Related