CS 213: Sample Assignment


The assignment that follows is completely fictitious but is present to illustrate how an assignment should be turned in. The format I use here is not required; the idea is simply that you take the time to write up a little information about the assignment instead of just handing us a printout of code.

Part 1 is the write up:
Ron DiNapoli                                   CS 213
Assignment #0                                  8/26/99


THE ASSIGNMENT
The assignment at hand is to write a program which 
prints our name out 20 times, says goodbye and then quits.  

THE SOLUTION
The most complex part of the assignment is the loop we use to
count how many times we are to print out a name.  I have
chosen to use a "for" loop since it offers the most control and
convenient syntax. The statement:

  for (x=0; x<20; x++)

causes the loop to be exercised 20 times.  Once this is in place
all we need do is add a "cout" statement within the for loop 
to print out a name everytime through the loop.  So our loop
looks like this:

  for (x=0; x<20; x++)
    cout << "Ron DiNapoli" << endl;

OTHER SOLUTIONS
There are other ways to achieve the same results without using 
this loop and they were considered.  First, we could simply write
a program which had the line:

  cout << "Ron DiNapoli" << endl;

20 times in succession.  The other potential solution would be
to use a "while" loop instead of a for loop.  This solution would
have worked just as well, but it means adding an additional 
line or two of code into the loop to manually keep track of how
many times we've been through the loop, like this:

  int counter = 0;
  while (counter < 20)
  {
    cout << "Ron DiNapoli" << endl;
    counter++;
  }

Part 2 is the code:
//
// printname.cpp 
//
//   Prints your name over and over again
//
// by Ron DiNapoli
// CS213 - Assignment #0
//

#include <iostream>

int main()
{
  int x;      // Used as the counter variable in the for loop

  // Print out my name 20 times
  for (x=0; x<20; x++)
    cout << "Ron DiNapoli" << endl;

  // Say "goodbye"
  cout << "Good-bye." << endl;
}

Part 3 is the sample run:
Ron DiNapoli/Assignment #0/Sample Run:

Ron DiNapoli
Ron DiNapoli
Ron DiNapoli
Ron DiNapoli
Ron DiNapoli
Ron DiNapoli
Ron DiNapoli
Ron DiNapoli
Ron DiNapoli
Ron DiNapoli
Good-bye.

Again, be creative with your write up. This is certainly not a technical writing course, so we won't spend a lot of time on emphasizing what makes a good write-up (although we may make suggestions). You do need to try, however, because in a professional programming situation you do need be prepared to explain your code and why you chose to do it the way you did. On any given assignment, the write-up is worth 10 points (out of a total of 100). You will always get 5 just for trying. The remaining 5 will be awarded based on how well you communicate what you did in solving the assignment. Assignments turned in with no write-up will automatically lose 10 points.