CS 301 Labs

Lab 1 August 31 - September 2

Tuesday Lab -- Introduction and Writing your Web page

  1. Check to see if your esus account is up and running. You may have to get your username and password from Jeanette or the TA.
  2. Become familiar with the class web pages. A class like this has information on several different web pages, all linked together. A lot of the information you will want to read only once, but you will need to read it once, and be able to find it again if need to.

    2. Writing Your Web Page


For Thursday, September 2

You will not have to turn anything in for this lab.

  1. Publish your web page on esus and show it to Anne
  2. Become familar with theC++ enviroment

  3. Create a few simple C++ programs


Summary of homework for the first week

You should have the following done BEFORE you come to the lecture at 2:00 on Tuesday, September 7:
  1. For the Theory part of the course
  2. For Lab

Week 2: Basic C++ Programs

Due Tuesday, September 7, 2004


Due Thursday, September 9, 2004

  • Do Exercises #9 and #10 on pages 72 & 73
  • Extra credit: # 11 and/or #12 on page 73.
  • Hand in:

    You need to hand in a hard copy of your source code and be prepared to demo the execution of the programs above to Anne during lab.


    Week 3: Loops and Decisions

    Do Tuesday September 14

    This will be due Thursday of this week

    Week 4:

    Do Tuesday September 21

    This will be due Thursday of this week

    Do Thursday September 23


    Week 5: Functions

    September 28 and 30
    This will be due Tuesday of next week
    1. Do #3 on page 212 in Lafore. The answer to #3 is in the back of the book, so #3 does not have to be turned in.
    2. Do #5 on page 212
    3. For practice using functions with structures do #6 on page 212. This will involve doing #9 and #11 from Chapter 4 in Lafore (page 159). After you do #9 and #11 from page 146 then complete #6 on page 212. You will not need to turn #9 and #11 in.
    4. Do #8 and on pages 213 of Lafore.
    5. Do #12


    Week 6--Using Functions

    For the week of October 5 and 7
    These will be due Tuesday, October 12.
    1. Write a program that will read in a length in feet and inches and will output the equivalent length in meters and centimeters. Use at least three functions: one for input, one or more for calculating, and one for output. Include a loop that lets the user repeat this computation for new input values until the user says he or she wants to end the program.

      There are 0.3048 meters in a foot, 100 centimeters in a meter, and 12 inches in a foot.

    2. Write a program that plays the game of "guess the number" as follows: Your program chooses the number to be guessed by selecting an integer at random in the range 1 to 1000. The program then types: the player then types a first guess. The program responds with one of the following: If the player's guess is incorrect, your program should loop until the player finally gets the number right. Your program should keep telling the player Too high or Too low to help the player "zero in" on the correct answer.

    3. In cold weather, meteorologists report an index called the wind chill factor,that takes into account the wind speed and the temperature. The index provides a measure of the chilling effect of wind at a given air temperature. Wind chill may be approximated by the formula

      where

      Note that the temperature must be less than 10 degrees before this formula is valid.

      Write a function that returns the wind chill index. Your code should ensure that the restrictions on tempture is not violated. The function should be restricted to one task, returning the wind chill index. Everything else should be done in the main program, perhaps calling other functions to do the I/O, etc.



      Week 7: Objects and classes

      October 12
      This will be due Tuesday, October 19


    Week 8: Using Arrays

    October 19
    This will be due Tuesday, October 26


    Week 10: 2-D Arrays

    November 2
    This will be due Tuesday, November 9


    Week 11: Overloading Operators

    November 9
    This will be due Tuesday, November 16

    Week 12: Inheritance

    November 16
    This will be due Tuesday, November 23

    1. From the Lafore book, on pages 424 and 425, do #1,3, and 4. The solutions for # 1 and 3 are in the back of the book, but you should try to do them on your own before looking at the solutions. Number 4 builds on 1 and 3.

      The next part is still under construction...I am trying to add notes to help you understand what is wanted

    2. Many programs written with inheritance could be solved with composition instead, and vise versa. Consider the relative merits of these approaches in the context of the Point,   Circle,   Cylinder   class hierarchy given.

    Week 13--Practice Programming and Logic

    A guessing game: Bagels

    This is a programming assignment suggested at a recent SIGCSE (Special Interest Group, Computer Science Education) conference. It comes from Stuart Reges at the University of Arizona.

    You are to write a program that plays a game known as Bagels. It is a variation of Mastermind. You may want to scroll down for sample output which explains how the game is to be played and explains its rules before reading about the assignment.

    The Assignment

    The Game

    This version of the Bagels game does not have a limit on the number of guesses the user can make.

    Here is a sample output from execution.

    	Welcome to Bagels.
    	Do you want instructions?
    	Y or N --> y
    
    	********** you may shorten or rephrase these instructions *****************
    	This is the game of Bagels.  You may know it as mastermind,
    	but we use digits.  In Bagels, I will think of an n-digit
    	number that you will try to guess.  You will specify what
    	value of "n" you wish to work with for each game.  
    	
    	After each guess I will give you some hints as to how close you 
    	are to getting the answer right.  If you have a digit right and 
    	in the right position, I will say FERMI.  If you have a digit
    	right but in the wrong place, I will say PICA.  
    	
    	So if the number is 123 and you guess 329, I will report FERMI PICA.  
    	If the number is 123 and you guess 312, I will report PICA PICA
    	PICA.  Each digit will match only once.  So if the answer is
    	999 and you guess 912, I will report FERMI.  If the answer is
    	912 and you guess 999, I will also report FERMI.  Notice that
    	I might report several FERMIs or PICAs in one message.
    	I will list all of the FERMIs first and then all of the
    	PICAs.  So if the answer is 12345 and you guess 31245, I will
    	say FERMI FERMI PICA PICA PICA.  So don't assume anything
    	from the order of my clues.
    
    	You will specify the number of digits you want to work with.
    	Obviously the game is not worth playing for 1 or 2 digits.  I
    	will set the upper limit at 50 digits.  Also, I will not include
    	any zeros in my numbers.  It makes for strange situations.
    	*********end of instructions you may shorten ************************
    
    	I will require from you that you give me exactly 'n' digits
    	each time as a guess.
    	
    	How many digits do you want to work with this time? 4
    	I'm thinking of a number . . .
    	Guess --> 12345678
    	That guess was too long, try again
    	Guess -->           123
    	That guess was too short, try again
    	Guess --> 1234
    	PICA PICA 
    	Guess --> 4356
    	FERMI PICA 
    	Guess --> 4178
    	PICA PICA 
    	Guess --> 7495
    	FERMI FERMI PICA 
    	Guess --> 7499
    	FERMI FERMI 
    	Guess --> 7744
    	FERMI PICA 
    	Guess --> 7455
    	FERMI FERMI FERMI 
    	Guess --> 7451
    	FERMI FERMI FERMI 
    	Guess --> 7452
    	You got it in 9 guesses.
    	
    	Do you want to play again?
    	Y or N --> y
    	How many digits do you want to work with this time? 4
    	I'm thinking of a number . . .
    	Guess --> 1234
    	PICA 
    	Guess --> 4567
    	PICA 
    	Guess --> 3789
    	FERMI PICA PICA 
    	Guess --> 2698
    	FERMI PICA PICA 
    	Guess --> 3968
    	FERMI PICA PICA PICA 
    	Guess --> 3896
    	You got it in 6 guesses.
    	
    	Do you want to play again?
    	Y or N --> n
    	OK, your average score was 7.5 tries per game.

    Week 14--Linked Lists

    November 30; This will be due December 6

    Write a clast LList to implement the Linked List Data structure. Your class should:

    1. Enable a client of the class to manipulate a list of integers. The client should not be aware of how the list is being stored. (i.e. the implementation details are hidden from the client)
    2. Include as much functionality as you can; the important thing is to get it running, test it, then include additional functions. Some suggestions for functions are:
    3. You may use any of the code I gave you in class, or any of the code in the book. You should understand how any code you use is working!
    4. You must also write a client (driver) to test each function.
    5. The I/O might looks something like this:
      		What would you like to do?
      		1) Insert an integer at the front of the list
      		2) Insert an integer at the end of the list
      		3) Delete an integer at the front of the list
      		4) Delete an integer at the end of the list
      		5) Insert an integer into tthe proper place to keep the list in order
      		6) Delete a specific integer
      		7) Output the list  
      For each item in the menu, the driver should prompt the user for input, the do the desired operation.
    This is the final lab assignment for the semester.