There are two sets of CMIS140 programming assignments; one set done in groups, the other individually:

  1. The Group programs 1 - 3 must be done in a group of 2 (one group of 3 may be allowed). You must work with a different person for each group program assignment. By the end of class Thursday before the work is due you must tell me your partner’s name in writing.
  2. Individual Programs 1 through 4 must be done alone. You may not work with anyone else for these 4 programs. Using anyone else’s work constitutes cheating and will rejust in a Zero grade for all people involved in any way.

 

All programs must meet the following requirements:

1. Coding and Documentation

  1. Avoid excessive comments by using meaningful variable names.
  2. Add comments to your code to describe and delimit blocks of code that have different functional purposes.
  3. Avoid literals by using named constants.
  4. Use consistent indentation (4 spaces) as necessary.
  5. In comments at the top of your program, provide your name, the course id, the type and number of this assignment; the purpose, and limitations of the program. For example:

/*AUTHOR: Harry Potter

  COURSE: CMIS140

  PROGRAM or GROUP: #1

  PURPOSE:  provide a brief overall functional description describing what your program does but not how it does it

  LIMITATIONS: may include such lacking features as error checking, or that a program only works for certain types of data such as grades 0-100. A limitation, then, is anything you should improve if given more time to work on the program. */

2. What to hand in (or email to me) all assignments:                  

  1. diskette containing any data files and your program source code (email just the text contained in the cpp file; do not use an attachment)
  2. program listing (i.e., printed listing of source code)
  3. printed program output

3. Grading: Code will be graded for

A. correct output,

B. adherence to the programming assignment requirements,

C. ease of reading, and

D. overall presentation.

The sample program below meets these requirements

//*******************************************************

// Author(s):    Robert C. Shields

// Course:                    CMIS140

// Program:                  #0 - Skeleton program

// Purpose:                   used as a prototype .cpp file to save typing

// Limitations:              could add samples of each control structure

// Date:                        3 Jan 2003

//*******************************************************

                                                // extra include statements should be removed

#include <iostream>               // for cin &

#include <string>                    // for string object class

#include <iomanip>                // for setpercision, etc.

#include <cmath>                    // for sqrt, fabs(floatx) & other math functions

#include <fstream>                 // for file IO

#include <cstdlib>                  // for abs(i), labs(longi) functions

#include <cfloat>                    // for FLT_MAX, LDBL_MIN, etc.

#include <climits>                  // for ULONG_MAX, CHAR_MIN, etc.

 

using namespace std;

 

int main() {

    cout << "program starts!" << endl  ;

/*

            // declare input and output files

            ifstream inData;         

    ofstream outData;        

    outData << fixed << showpoint       // Set up floating pt.

            << setprecision(2);                  // output format

 

    // Open the files

    inData.open("myin.dat");

            if (!inData) cout <<" error opening input file" << endl;

    outData.open("results.dat");

            if (!outData) cout <<" error opening output file" << endl;

*/

            // sample code to show ranges

            cout <<" floatMax: " << FLT_MAX

                        << "\n longDblMin: " << LDBL_MIN

                        << "\n charMin: " << CHAR_MIN << endl  ;

 

    cout << "\a\aprogram ends!" << endl; // \a(lert) = bel

    return 0;

} // end main()

 

Individual and Group Assignments:

Individual Program #1 –Basic Flow Control Review

1. Purpose: To review the use of logical expressions, while loops, and library functions. If you are unable to do this program, you should take CMIS 102 instead and take CMIS140 later.

2. The Problem: Write a program that prompts the user to enter the coefficients a, b, and c of a quadratic equation :  ax2 + bx + c = 0   then prints out its roots to 3 decimal places.

3. More Details:

Determine the roots (root1 and root2) of the equation using the quadratic formulas shown in chapter 5, warm up exercise #11 of our textbook.

After each calculation, your program should ask the user if he or she wishes to continue. The program continues to another calculation if the user enters 'Y' or 'y' and quits if the user enters 'N' or 'n'.

You will need to use the sqrt(nbr) library function discussed in chapter 2 of the text.

4. Error Checking: Do not attempt to calculate x1 and x2 if the discriminant, b2 - 4ac, is less than zero. In this case, the roots of the equation are imaginary.

5. Input data: Use input of a=1, b=4, c=3.  Also create input data which will cause the denominator to be zero, demonstrating an error message.

6. Output:

The first 80-character line on your output should consist of:

·         your name, left-justified

·         "CMIS140: Program #1", centered

·         the due date (mm/dd/yy) for the assignment, right-justified

Each entry in the body of your output should have the following format:

Quadratic Calculator
=============
Enter quadratic coefficients a, b, and c: <User enters, for example: 22.4 5.8 3.6>

The roots of the equation are: x1 = <answer>, x2 = <answer>

Do you want to continue (Y or N)?

If the discriminant is negative, then use x1 = Imaginary, x2 = Imaginary

Group #1 – Functions

Write complete programs to test the code specified in the Programming Warm-Up Exercises:

Page 363: #3 – Average,  and #8 - Rotate.

Individual Program #2 – File I/O

Write the program to test and run the code specified in the following Programming Problem:

Page 365: #2 – Binary Conversion.

Group #2 – More Control Structures

Write complete programs to test the code specified in the Programming Warm-Up Exercises:

Page 464: #4 – DoWhile, and #7 – ForLoop;

And Page 467 Programming Problem: #4 - Switch.

Group #3 – Types

Write complete programs to test the code specified in the Programming Warm-Up Exercises:

Page 543: #8 through #11 – Days (or dazed).  You may do this all in one program if you document each step clearly.

Individual Program #3 – Functions

Write the program to test and run the code specified in the following Programming Problem:

Page 434: #3 – Projectile Distance.

Individual Program #4 – Classes

Write the program to test and run the code specified in the following Programming Problem:

Page 628: #5 – Timer. (for more exercise, add minutes then hours)