CSCI 151 - Prelab 1

Due at the start of class on Monday September 17

In this prelab, you will be working on some of the issues related to the first full lab assignment.  Please write up or type up your solutions and hand in a paper copy at the start of class on Monday.  Remember: no late prelabs allowed!

This lab will consist of a number of small programming problems to give you a chance to become familiar with programming in Java.  There is one prelab question for each of the programming problems.

Return to the Pyramids

You may recall from 150 having to draw a Pyramid out of bricks. This time you will build a pyramid out of stars. They will be symmetrical and look like:

  1. Given a pyramid of height N, how many stars are in row i (0 <= i < N)?  How many spaces precede the stars in row i?

HiLo guessing game

You and your friend (the computer) will play a guessing game.  One of you will pick a number between 1 and 1000. The other one will guess numbers and the other will tell them if they guessed correctly or were too high/low.

  1. A game like this typically ends when one of two things happens.  What are they?


  1. Describe how you could accurately determine the number of lines in a text file.  You can do this in Java or Python or pseudocode.

Benford's law

Take a look at the Wikipedia entry for Benford's Law.  We are going to compute the frequency distribution of the initial digits in some data files and see if this distribution (Benford's aw) actually holds for them.  As part of this, we will be drawing a simple text-based histogram chart based on the frequency of the digits.

  1. Describe the data structures (i.e., lists, etc.) you would use to perform this calculation.  (Think:  If you were going to do this by hand with pencil and paper, what would you be keeping track of and how?)