Stepwise Refinement From the Inside out - PowerPoint PPT Presentation

1 / 6
About This Presentation
Title:

Stepwise Refinement From the Inside out

Description:

Consider a program that reads in a file from the Census tables of populations ... Xavier Xenon Jr m090400 78, 80, 82, 84, 86, 88, 90; ... – PowerPoint PPT presentation

Number of Views:78
Avg rating:3.0/5.0
Slides: 7
Provided by: need9
Category:

less

Transcript and Presenter's Notes

Title: Stepwise Refinement From the Inside out


1
Stepwise Refinement From the Inside out
  • For larger programs, need to compile, run, and
    test the intermediate stages. Allows you to
    continually refine program so that it solves
    progressively more of your initial problem.
  • Consider a program that reads in a file from the
    Census tables of populations and population
    densities and prints out a list of all the towns
    in the state.
  • (For example, take a look at Maryland's
    geographic census data.)
  • This is difficult, in part because towns' names
    are not always a single word, for example East
    New Market.

2
Basic Structure of the Program
  • For now, lets assume a file "tempdata" contains
    the data. With this assumption, program becomes

3
Consider some simple data first
  • Initially simplify problem by ignoring files
    header info, and look at only a single row of
    data
  • Looking at 1st single row of data we see 7
    pieces of info to be read in (and ignored) before
    we come to the town name, in this case
    Aberdeen.

4
Refine to account for Compound Town Names
  • Below works for towns like Aberdeen but fails
    for town names like Bel Air that are more than
    one

word. Need to keep reading in words, stopping
when we read in town or city or CDP or village
and saving the towns complete name.
5
Completed Program
  • Allows the user to enter a filename
  • Ignores header (which ends in NAME
  • Loops thru file

6
ICE Finding the Highest Average
  • You are given a list of midn names and alpha
    codes followed by a list of grades followed by a
    Print out the name of the student with the
    highest average. The format of your input is
    demonstrated in this example
  • John Jeffery Jones m090101 85, 95, 22, 54
  • Sandra Smith m090201 99, 98
  • Xavier Xenon Jr m090400 78, 80, 82, 84, 86, 88,
    90
  • For this input, your program would print out
    Sandra Smith had the highest average.
  • Hint If S is an object of type string and c is
    an object of type char, then c S is the string
    object you get by tacking the character c onto
    the beginning of S.
Write a Comment
User Comments (0)
About PowerShow.com