1 / 26

Clearly Visual Basic: Programming with Visual Basic 2008

Clearly Visual Basic: Programming with Visual Basic 2008. Chapter 3 First You Need to Plan the Party. Objectives. Identify the output and input in a problem description Plan an algorithm using pseudocode and flowcharts Desk-check an algorithm. How Do Programmers Solve Problems?.

nancyrogers
Download Presentation

Clearly Visual Basic: Programming with Visual Basic 2008

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. Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 3 First You Need to Plan the Party

  2. Objectives • Identify the output and input in a problem description • Plan an algorithm using pseudocode and flowcharts • Desk-check an algorithm Clearly Visual Basic: Programming with Visual Basic 2008

  3. How Do Programmers Solve Problems? • You cannot solve a problem unless you understand it • You cannot understand a problem unless you analyze it • Most important components of any problem are the problem’s output and its input Clearly Visual Basic: Programming with Visual Basic 2008

  4. Clearly Visual Basic: Programming with Visual Basic 2008

  5. Step 1 – Analyze the Problem • Identify output • What does the user want to see printed on paper, displayed on the screen, or stored in a file? • Identify input • What information will the computer need to know to print, display, or store the output items? • Analysis step is most difficult problem-solving step Clearly Visual Basic: Programming with Visual Basic 2008

  6. Clearly Visual Basic: Programming with Visual Basic 2008

  7. Clearly Visual Basic: Programming with Visual Basic 2008

  8. Clearly Visual Basic: Programming with Visual Basic 2008

  9. Step 2 – Plan the Algorithm • Pseudocode • False code, not standardized • Cannot be understood by a computer • Used by programmers when planning an algorithm • Flowchart • Uses standardized symbols to visually depict an algorithm Clearly Visual Basic: Programming with Visual Basic 2008

  10. Clearly Visual Basic: Programming with Visual Basic 2008

  11. Step 2 – Plan the Algorithm (continued) • Flowchart symbols • Oval: start/stop symbol • Parallelogram: input/output symbol • Rectangle: process symbol • Flowlines • Connect symbols • Processing item: intermediate value that algorithm uses when processing input into output Clearly Visual Basic: Programming with Visual Basic 2008

  12. Clearly Visual Basic: Programming with Visual Basic 2008

  13. Clearly Visual Basic: Programming with Visual Basic 2008

  14. Clearly Visual Basic: Programming with Visual Basic 2008

  15. Clearly Visual Basic: Programming with Visual Basic 2008

  16. Step 3 – Desk-Check the Algorithm • Desk-checking (hand-tracing) • Programmer reviews algorithm while seated at his or her desk • Valid data • Data that algorithm is expecting user to enter • Invalid data • Data that algorithm is not expecting user to enter Clearly Visual Basic: Programming with Visual Basic 2008

  17. Clearly Visual Basic: Programming with Visual Basic 2008

  18. Go to Page 33 Desk Checking State Income Tax $23,000 and 3% State Income Tax $23,000 * .03 = $690 $14,000 * >02 = $280 Desk Check CD Purchase20* $10.50 = $210.00 (Club Price)20 * $14.99 = $299.80 (Regular Price)Total Savings = $89.80 Clearly Visual Basic: Programming with Visual Basic 2008

  19. Summary • First three steps in the problem-solving process • Analyze the problem • Plan the algorithm • Desk-check the algorithm • Programmers use tools to organize their thoughts • Pseudocode • Flowcharts Clearly Visual Basic: Programming with Visual Basic 2008

  20. Summary (continued) • Algorithm • Enter data • Process data • Display, print, or store data • Calculation instructions in an algorithm • Specify what is to be calculated and how to perform calculation • After completing analysis and planning steps • Programmer desk-checks algorithm Clearly Visual Basic: Programming with Visual Basic 2008

  21. Review Questions- Page 37 • Programmers refer to the items needed as: Input, output, processing or Purpose • The calculation instruction in an algorithm should state:only what is to be calculated, only how to calculate something, both what is to be calculated and how to calculate it • Most algorithms for this flow: (arrange the following)Entering the input items: Displaying, Printing or Storing the output items: Processing the output items • In a flowchart, what symbol represents an instruction that gets information from the user: enter, process, input/output, start/stop • When desk-checking an algorithm, set up a table that contains:one column for each input and one column for each outputone column for each input and one column for each processing itemone column for each processing item, and one column for each input itemone column for each input item, one column for each processing item, and one column for each output item

  22. Review Answers- Page 37 • Input • Both what is to be calculated and how to calculate it • Most algorithms for this flow: (arrange the following)Entering the input items: Processing the output items Displaying, Printing or Storing the output items: • Input/output • one column for each input item, one column for each processing item, and one column for each output item

  23. Page 38 Exercise 3 Output: tip credit card charge Input: total bill liquor charge tip percentage Algorithm: 1. enter the total bill, liquor charge, and tip percentage 2. calculate the tip by subtracting the liquor charge from the total bill, and then multiplying the remainder by the tip percentage 3. calculate credit card charge by adding the tip to the total bill 4. display the tip and the credit card charge Desk-check table total bill liquor charge tip percentage tip credit card charge 505.2959 15 0 .15 2.25 17.25 Clearly Visual Basic: Programming with Visual Basic 2008

  24. Page 39- Problem 7 Output total fee Input: base fee charge per mile miles driven Algorithm: 1. enter the base fee, charge per mile, and miles driven 2. calculate the rental fee by multiplying the charge per mile by the miles driven, and then adding the base fee to the result 3. display the rental fee Desk-check table rental fee base fee charge per mile miles driven 250 50 .2 1000 185 60 .25 500 Clearly Visual Basic: Programming with Visual Basic 2008

  25. Page 39: Number 8 Output: total bill • Processing: room charge ($55 * Number of Days) • entertainment tax (Room Charge * Entertainment Percent) • Input: per-night rate ($55) • nights stayed • entertainment tax rate • room service charge • telephone charge • Algorithm: • enter the per-night rate, nights stayed, entertainment tax rate, room service charge, and telephone charge • calculate the room charge by multiplying the per-night rate by the nights stayed • calculate the entertainment tax my multiplying the room charge by the entertainment tax rate • calculate the total bill by adding together the room charge, entertainment tax, room service charge, and telephone charge • DESK CHECK • nights stayed entertainment tax rate room service charge telephone charge • 2 .05105room charge entertainment tax room service charge telephone charge total bill • 110 5.50 10 5 130.50 • Total Bill = $130.50 Clearly Visual Basic: Programming with Visual Basic 2008

More Related