Keep this nearby at all times! Points will be lost on programming assignments for not adhering to these standards!
You must put the various sections of your C++ programs in the following order:
There should be blank lines between each of these sections.
//--------------------------------------------------------------------- // // Name: your name // // Course: CS 226, Section 060A, Fall 2002 // // Purpose: General description of what the program does. This should // be at least several lines long and should discuss the // purpose of the program, the format of the input, and the // output the program produces. This information should be // from a programmer's perspective (as opposed to the user's // perspective). // //---------------------------------------------------------------------
Note that you can use cut and paste to copy this header into new programs.
//--------------------------------------------------------------------- // A few lines describing what the function does. // params: (in/out/inout, ...) //--------------------------------------------------------------------- result_type function_name(type1 param1, type2 param2, ...)
For example,
//--------------------------------------------------------------------- // This function uses hours and rate to compute and return the gross // pay and the net pay of an employee. // params: (in, in, out, out) //--------------------------------------------------------------------- void ComputePay(int hours, float rate, float& GrossPay, float& NetPay)
count = count + 1; // add one to count
is a useless comment. For the most part, you shouldn't need more than one line of comments within functions for every few lines of code. The exception is for very difficult sections of code, where several lines may be needed.
const int CLASS_SIZE = 25; // students in class
Be sure to give these constants meaningful names; the name TEN in
const int TEN = 10; // useless!
doesn't add to the understanding of the program at all. Any value other than 0 or 1 must be given a name in a constant declaration.
You
are responsible for proper indentation. MVC++ provides help, but you cannot depend on it to do all the work of indenting your program correctly. If you are using your own version of Turbo C++ or some other compiler, make sure the environment option "insert tab characters" or the equivalent in your system is turned off; this will ensure what you see on the screen is the same as what we grade. cout << "The cost for 1 loaf of bread" << endl
<< "is $1.89" << endl; if ( radius > 0 )
{
area = PI * radius * radius;
}Submit based on these handouts . Your project should include the following parts (source code is mandatory and program should be executable):