CSSE 120 -- Intro. to Software Development

Homework 11

  1. Read Sections 9.1 and 9.2 of Zelle.
  2. (8 points) Complete the ANGEL quiz, Simulation and Design I, over these sections. You will find this quiz in the Homework 11 folder on ANGEL.
  3. (20 points) Star graphics problem: See question 5 of the previous homework assignment for details.  Once you have done it, commit your Session10 project to your SVN repository.
  4. (60 Points) Speed Reading: Average all of the numbers from an input file (perhaps with multiple numbers on some input lines).

    This problem is a bit longer, requiring you to combine the ideas of:

    Your task is to read numbers from a file and calculate the mean of the numbers. Unfortunately, the file is a bit malformed. The numbers are generated by a radar gun that measures the speed of each vehicle on the road coming up the hill from the SRC. Due to an intermittent open circuit occasionally multiple numbers are written on a single line, like this:

    23.2 15.6 19.8

     A sample input file, speeds.txt, is in your project.

    Open the speedReading.py file in the Session11 project that you checked out from SVN in class. Modify it to calculate the arithmetic mean (average) of the numbers in a file. Your program must conform to the following specifications:

    1. Your program should use the four functions as given in speedReading.py:
      1. lineSumAndCount()
      2. fileMean()
      3. getInputFile()
      4. main()
    2. When you write more complicated programs, you should be able to test them as you go. Typically, software developers write a set of tests for each small part of the program (thus they are called "unit tests"). We've given you unit tests for the first 2 functions in the file speedReadingUnitTests.py to help you. So,
      1. Write lineSumAndCount() first
      2. Then run speedReadingUnitTests.py  to make sure it works.
      3. Then write and test fileMean() in the same way.
      4. Finish up by creating the GUI and testing it on the file speeds.txt in your project by running speedReading.py. The average of the speeds in that file should be around 20.16.
    3. Your program should ask the user for the name of the input file to process. Rather than using “console” input, your program should use a GUI similar to the one in Figures 5.9 and 5.10 on pages 150 and 151 of Zelle’s text book. Use an Entry object (Zelle, page 148) to accept the input file name from the user.
    4. Your program should display the final average in the GUI window. Hint: You can use the setText() method to change the displayed value of a string that has already been drawn.
    5. Yes, there are many other ways that you could write this. We're asking you to follow our specification so you can get practice working with the sort of situations that come up in real world, group projects, where you often must implement someone else's design.  We also think that doing it this way will get you to confront some issues and clear up some misunderstandings that you may have about functions.
    6. Commit your file to your SVN repository.
  5. BONUS: (10 Points) Augment your program so that it also displays, at the bottom of your window, a bar graph of the data read in, along with a horizontal line showing the mean speed. You are allowed to pass more parameters to your functions to get it to work. For example, you will probably need to pass the window to the  lineSumAndCount function for it to display individual vertical lines as you read each number from the file:

  6. Be sure to commit your new code back to SVN so it can be graded.
  7. Web link: Debugging, by Dave Agans. A book on debugging that can be helpful to neophytes as well as pros. See the sample chapters at the bottom of the web page!