[Skip Navigation] [CSUSB] / [CNS] / [Comp Sci & Eng Dept] / [R J Botting] / [CSci201] / projects
[Text Version] [Syllabus] [Schedule] [Glossary] [Labs] [Projects] [Resources] [Grading] [Contact] [Search ]
Notes: [01] [02] [03] [04] [05] [06] [07] [08] [09] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20]
Podcasts: [01] [02] [03] [04] [05] [06] [07] [08] [09] [10] [11] [12]
Labs: [01] [02] [03] [04] [05] [06] [07] [08] [09] [10]
Wed Mar 12 13:01:48 PDT 2008

Contents


    Notes on Projects for CS201

      Style

      See the following book's style guide [ styleguide.html ] and follow it.

      Documentation

      You should document who you are, what you are doing, and any help you get. Documentation should be included in the source code as far as you can. At the minimum each program must contain comments that identify who did the work and which project the program is tackling. Use the template [ project.cpp ] to get started. Keep a copy with your name to reuse in each project.

      Assigned Programming Projects


      (P1): Program a straight forward input-calculate-output program. This may be the one you described in the first class, or it may be one of the book's exercises: 2.1, 2.2, 2.4, or 2.7 from chapter 2, or a program that does something like one of these calculations:
      InputOutputNote
      radius of circlecircumferenceNeeds <cmath> and π =4*atan(1).
      radius of circleareaNeeds <cmath> to calculate π =4*atan(1).
      Base and height of a trianglearea
      Base and height of right angled trianglehypotenuse<cmath> has sqrt (square root)
      Or any other similar calculation. Due start of class 05. Grading: The code should compile, run, do the right thing, and follow the Style described in the book. Since this is difficult to do all at once.... most projects can be resubmitted. Start by downloading this sceleton program [ project.cpp ] and fill in the blanks.


      (P2): Review our comments, improve, and resubmit P1. In particular include at least one if-statement. Typically this will only do the calculation of the output if the given data is acceptable. Due start of class 07. Graded viciously.


      (P3): Decisions and loops. Take the marked up and graded version of P2 and add a loop to it so that the user can solve a series of problems with a single run of your program. Due at the start of class 09. This will be graded viciously.


      (P4): Vectors, arrays, and strings. Pick one of these exercises from the book and do your best: 2.15, 2.16, 2.18, 2.19, 2.20, 3.1, 3.2, 3.3, 3.4, or 3.5. Due start of class 11. Graded Gently -- the program should compile and run. It should have a cooment that indicates any bugs or any compile errors you haven't fixed.


      (P5): Correct and improve P4. Resubmit. Graded viciously. Due in at start of class 13.


      (P6): Writing functions and/or procedures. You must have at least one function defined in your program plus a main program that tests all the functions you have written for several argument values. Attempt one(1) of these exercises from chapter 4 in book: 1,2,3,4,5,6,7,8,10,11,13,14,15*,16,19,20. There is no credit given for choosing a tough problem. Due start of class 15. Graded gently. However to get any credit I expect you to have at least two functions in you handed in program. The main program that does the test and another function that matches the table below:
      Exercise#Function Header
      1int signum(int i)
      2bool prime(int n)
      3bool perfect(int n)
      4int c(int n, int k)
      5double macexp(double x)
      6double mypow(double x, double y)
      7int gcd(int m, int n)
      8double root(double x)
      10bool variable(string t)
      11void lowerUppper(string t, int & lower, int & upper)
      13int substring(string t1, string t2)
      14void put_romany(string t)
      15*bool equal(vector <int> a, vector <int> b)
      16vector rotate(char [] a, int length, int number)
      19int gcd(int m, int n)
      20void putBinary(int n)
      * Note -- replace arrays by vectors in exercise 15!

      Hint: start by writing the main program (which will fail) first then add the function to make the main program work.


      (P7): Review our comments, improve, and resubmit P6 Due start of class 17. Graded viciously.


      (P8): Classes. In P8 your program must include a class that follows the instruction of an exercise in the book. More, in P8, include a main program that tests every member function and constructor. Select one(1) from this list of exercises from the book:

      1. 7.1(not the Counter in class), {Hint: at first assume that there will be boundaries and get that to work...}
      2. 7.3(includes 7.2),
      3. 7.4(start by copying the book's code [ code.cpp ] ),
      4. 7.5 (correct the formula given if it is wrong in your copy!) [ Distance#Geometry ]
        7.7(needs gcd),
      5. 7.8(start by copying the book's code),
      6. 7.10(real but tough),
      7. 8.6(easy if you are happy with the sqare root of -1).

      Due start of class 19. Graded gently. You may be asked to draw a UML diagram of your class in a quiz or final.


      (P9): Review our comments, improve, and resubmit P8 . Due start of final. Graded viciously. There will be questions on the final that will ask you to draw a UML diagram of the class you implemented in this project.

      Deadlines

      Projects are due at the start of the class on the due date.

      Late work is worth zero. Incomplete or incorrect work is worth something.

      Rushing to print out the work at the last minute and arriving late is likely to cost you all the points.

      Deliverables

      Hand in a print out of the source code of the programs. Print, staple the pages, and hand in. No cover sheets or folders. Note: all source code should start with the identifying information. In an emergency you could send the code (ASCII/.txt) with a subject like these
       	cs201/P1

      Start Early!

      Look for this file on the CS201 web site: [ project.cpp ] as a starting point. Download and/or save it. Edit in your name. Use it to get started on each project. All the projects in this class can start form this file.

      Grading

      There is absolutely no extra credit given for choosing a difficult project. Good programmers don't let their ego make things difficult for themselves: always do the simplest thing that can possibly work.

      The grading on projects 1, 4, 6, and 8 is gentler than on projects 2, 3, 5, 7, and 9. In 1, 4, 6, and 8 any program that has the right comments and compiles without errors can earn an A. In later projects the program must compile and run without error and the code must meet all style guidelines.

      Advice for Project Work

        Compiling and running projects

        Compiling project code can be done by hand in a terminal window as shown in the classes or using the techniques demonstrated in the labs. Avoid using any software that costs you money.

        In a terminal window


          Simple programs can be compiled run and tested with a single command on our computers:
           		Q p1.cpp
          if the code is in file p1.cpp in your current working directory.

          On other systems you may have to do the steps in 'Q' by hand:

           		g++ -o p1 p1.cpp
          will compile it and
           		./p1
          will run it. You can repeat the last compilation by typing
           		!g++
          into a terminal or use the arrow keys.

          Or, for more complex projects with code in many files, you can create a Makefile by using any UNIX editor that contains lines like this

           test: p1
           	./p1
           p1 : p1.cpp
           	g++ -o p1 p1.cpp
          (be careful to use the <Tab> key to indent the commands.

        Then the command
         		make test
        will update p1 and then execute it for you.

        Warning -- Do It Yourself

        You can ask the teachers for help. Anything that looks like another student's work or a file downloaded from the Internet is likely to get a score of zero (0) for plagiarism. We have several tools that spot files copied from the Internet.

        Each project is matched with an examination. In the examination you will have to answer questions about your latest project.

        Recently, in CS201, someone desperately downloaded code from the internet that sounded like it might solve the problem. It didn't. It got zero.

        Again, in a recent Comp. Sci. course, one student got some code from his brother at another university and then let six friends copy it and make small changes. Six students handed in six variations of the code. It was a solution to a different problem. They all got zero.

        University Policy on Plagiarism

        Please read page 51-52 of the catalog.

        Do's and Don't's for Projects.


        1. Put your name and the project description as a comment in the code.
        2. Download this file [ project.cpp ] as the starting point for a project.
        3. Do the simplest thing that can possibly work.
        4. Look out and take note of any productivity and quality tips I mention in class.
        5. Put most of the documentation as comments in the code.
        6. Explain how a user uses the program -- what do they do and what do the get out of it.
        7. For complicated steps: write an algorithm (as a comment) first and then code it.
        8. Use variable and function names that say what their purpose is.
        9. Check out the links under Style above.
        10. No spelling errors in variable names, outputs, or comments. The command ispell filename.cpp will help.

        11. When you get to functions: use [ function.cpp ] as an outline with comments defining the function.

        12. When you get to classes: use [ class.cpp ] as a model and outline.

        THINK. If you rush into code and patch it until it works you may score less than someone who takes time to think about the problem and possible solutions before writing the code. You can make notes using an editor. Start with: What are inputs and outputs? and/or the givens and goals? and/or the before and after conditions? How are these connected? Make notes on this analysis of the problem. What are some possible ways of solving it (designs or algorithms)? Choose one. Turn your notes into comments at the top of a program.

        Make it Meaningful. It is up to you to use meaningful identifiers and comments that make it clear why the code is going to work. Don't hand in a separate algorithm or structure chart. Instead your file should include comments that show the design. A function definition should start with a comment saying (1) what it assumes and needs, (2) what it produces or guarantees, plus (3) a very brief algorithm. Make it clear and correct before you make it fast. Check all code before I grade it. If you have a bug: Add comments about the symptoms... remove the comments when fixed. If I find uncommented errors you will loose points. If I find things that I can't understand then you will also loose points.

        Most Errors occur when people (1) misunderstand the problem, (2) think of efficiency before correctness. Real problems are not obvious and are not clearly specified. The descriptions of the programs in the book are like this. There are several different programs that will fit what the book asks you to do. I leave the interpretation of them to you yet: (1) K.I.S.S. (= Keep It Simple!). (2) Demonstrate the features and topics described in the book and course at that time. (3) If in doubt A.S.K. (= Always Seek Knowledge). (4) Document (in comments) how you interpret the problem(Analysis)

        Always Seek Knowledge (ASK)

        I expect you to come and talk to me or other teachers about projects. You should be careful about talking to other students, however. They do not know enough to give you good advice. Also beware searching the Internet -- you'll probably find a solution to a differnt problem.

        Document It As You Go

        Real problems don't have obvious solutions. Whether you know what the code will look like or not add a comment that says what the program must do -- you can copy the description in the book. This may give you an idea. If not think up a special case that you can see how to solve. Use comments to describe the special case and how it case is solved. Make it compile! Add a simple output to see if the algorithm will work -- nothing else. It will probably have errors. This is normal. Declare variables and recompile and test. Add initial values. Test until it runs. Add comments describing an algorithm. Write code implementing the algorithm. Test.

        Divide and conquer

        Develop code in small iterations. Tackle one complication at a time. Test and retest. Rerun the previous tests.

        Don't let the sun rise on bad code!

        When the current version passes all tests, look for ways to re-factor code. For example use the DRY ( Don't Repeat Yourself ) rule to spot code that can be put in a loop or functions, etc.

        Stop!

        Stop before you are about to run out of time or when it does every thing that the book asked for.

        How to Fail a Programming Assignment

        Carol Edmondson at the University of Tasmania has documented the following techniques students have used to fail her courses:
        1. Don't submit the assigned work.
        2. Submit the work late.
        3. Submit the same document as your friend.
        4. Submit something you found on the web.
        5. Use Email/News/etc to invite someone else to do the work for you.
        6. Collect random pieces of code and put them in a file.
        7. Submit a program that doesn't compile without comment.
        8. Submit a program that produces a run-time error without comment.
        9. Submit a program that only works on the given tests.
        10. Submit a program that does not meet the specification without comment.

        Any of the above can loose you points.

      Working at home with SSH access

      You can work at home but do not spend money on a C++ system. (1) We require work to be work with the free and standard Gnu C++ system. (2) The expensive stuff adds complications to your code for no added value. The department and the Computer Science Club can provide you with software if you ask.

      You can access our system by using the same system that I have in the class room and office. This is the free Windows SSH client at: [ http://ftp.ssh.com/pub/ssh/ ] Download and install the latest SSHWinClient-3.x.x.exe file. Connect it to

              jbh3-1.csci.csusb.edu
      and log in. You then will need to login to a lab computer like this
       		ssh jb358-10
      (you can use any of these machines from JBH3-1).

      You won't be able to do graphic programs or use KDE to make things easier.

      A key rule:


      1. Tap Enter to end each command!

      The following UNIX commands work well:
      CommandPurpose
      cat >fUpload or input a file called f. You can type in the code or copy/paste it from your machine. End with Enter and Control/D
      cat fList the file f on your screen.
      g++ -o p p.cppCompile a program called p
      ./pExecute/run a program called p in this directory(.)
      make tFollow a recipe in Makefile to make t
      cd dchange working directory(folder) to d
      pwdPrint working directory
      ls List the file names in this directory
      file * List the files
      mkdir dMake a directory called d
      more fDisplay a file f one screen at a time
      rm fRemove a file (dangerous....)
      mv f nChange f's name to n, or move it to a directory
      cp f nCopy f to file n
      pico fEdit a file called f (easy to use but not powerful)
      vi fEdit a file called f (powerful but not easy to use)
      emacs fEdit a file called f (powerful and I can't use it)
      lynx uView a web page with URL u while on JBH3-1.
      links uView a web page with URL u.

    . . . . . . . . . ( end of section Notes on Projects for CS201) <<Contents | End>>

    Abreviations

  1. Gnu::="Gnu's Not Unix", a long running open source project that supplies a very popular C++ compiler.
  2. KDE::="Kommon Desktop Environment".
  3. OOP::="Object-Oriented Programming", Current paradigm for programming.
  4. SP::="Structured Programming", Previous paradigm for programming.
  5. TBA::="To Be Announced", something I should do.
  6. TBD::="To Be Done", something you have to do.
  7. UML::="Unified Modeling Language", [ 15.html ] (class notes on the UML and OOP).

End