Need help writing C++ programming assignment. Due by 700 am (central time) 8/2/2013

Dspace2
assignment.docx

Overview

Using the C-struct feature, design, implement and test a new (programmer-defined) data type that can be used to represent and manipulate a collection of sorted integers. Such a data type can be used, for instance, by an instructor to process test scores (assuming test scores are recorded as integral values); each instance (object) of the data type would be able to represent a group of related test scores in that case. The operations supported should include the following:

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

Checking to see if the collection is empty.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL2_5x12.gif

NOTE: A collection is empty if it doesn't contain any values.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

Finding the number of values in the collection.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

Adding a new value to the collection.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL2_5x12.gif

NOTE

You should  NOT  simply append the new item to the end of the array and then use a sorting algorithm of some kind to sort the array. You also should  NOT  use any temporary arrays to perfom the insertion.

TIP

Adopt/adapt the StoreOrdered function of  Assignment 4 .

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

Finding the collection's lowest/highest value.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL2_5x12.gif

NOTE

The lowest/highest value is undefined if the collection is empty.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

Finding the value at a given position in the collection, with position starting at 1 (i.e.array index 0 corresponds to position 1array index 1 corresponds to position 2, and so on).

http://cs.txstate.edu/~lk04/2308/Assign/BulletL2_5x12.gif

NOTE

A positional value is undefined if the collection is empty.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

Finding the collection's average.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL2_5x12.gif

NOTE

The average is undefined if the collection is empty.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

Removing an occurrence (if exists) of a specified value from the collection.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

Finding the number of occurences of a specified value in the collection.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

Resetting the collection to an empty collection.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

Adding a given collection into another collection.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL2_5x12.gif

NOTE

The given collection (addend) and the collection to be added to (benend) may be the same collection before the operation takes place (in which case the operation will result in "each of the items in the original collection is duplicated exactly once").

TIP

The "adding a new value to collection" function (assuming implemented correctly) should prove useful here.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

Combining two given collections into a third one (which is a new collection to be returned).

TIP

The "adding a new value to collection" function (assuming implemented correctly) should prove useful here.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

Testing to see if two given collections are identical.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL2_5x12.gif

NOTE

Two collections are identical if they contain the same number of items and the values contained in every corresponding pair of items are equal.

Some Specifics

You will use a fixed-sized, compile-time array (and other supporting data members) to implement the new data type that can be used to declare variables (objects) each of which can represent a collection of up to MAX_SIZE  integers. For the purpose of testing, set MAX_SISE to 10; your design and implementation of the data type, however, should enable the maximum size to be easily modified, i.e., only need to change the value that MAX_SIZE is set to.

Goal

To gain experience designing, implementing and testing a relatively simple programmer-defined data type using C-struct (and an action-oriented/procedural approach).

Supplied Files and Sample Executable

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

Supplied files

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

Sample executable

http://cs.txstate.edu/~lk04/2308/Assign/BulletL2_5x12.gif

Some caveats:

http://cs.txstate.edu/~lk04/2308/Assign/BulletL3_5x12.gif

It was compiled using one of CS department's Linux machines. Thus, it may not run on machines that have different Unix operating systems (including different versions of Linux). It definitely will not run on Windows.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL3_5x12.gif

To use the file, you should first do the following: (1) download the posted file (Assign06SampleExe.zip) onto you local machine, (2) unzip the downloaded file to obtain a6, and (3) upload the unzipped file (a6) to the desired working directory on your Linux account.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL3_5x12.gif

You will most likely get an error message such as the one shown below when attempting to run the program (by entering ./a6 while in the directory containing the file):

bash: ./a6: Permission denied

If this happens, it is because the access permission for the file got changed during download/upload. To fix the problem, do the following while you are in the subdirectory containing the uploaded file (a6):

chmod +x a6

http://cs.txstate.edu/~lk04/2308/Assign/BulletL3_5x12.gif

Let me know as soon as possible (via e-mail) if you face any difficulties using the file, or if you discover some errors in my program.

Your Tasks

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

Thoroughly study and make sure that you fully understand the supplied header file SortedInt.h and the supplied test driver file assign06.cpp – you shouldn't have to make any changes to these files but you have to understand what's in them.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL2_5x12.gif

NOTE

Your understanding (or lack thereof) of what's provided may affect your ability to answer some questions in exams.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

Implement all the functions whose specifications appear in the header file. For uniformity, start with the supplied (skeleton) implementation file SortedInt.cpp, where the  invariant  for the data type has already been written.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

Compile a test program using SortedInt.hSortedInt.cpp and assign06.cpp, and run the program using appropriate test cases. 

http://cs.txstate.edu/~lk04/2308/Assign/BulletL2_5x12.gif

An appropriate Makefile has also been provided for your convenience. If you have this Makefile in the same folder that you put the other files (SortedInt.hSortedInt.cppassign06.cpp, and a6test.in):

http://cs.txstate.edu/~lk04/2308/Assign/BulletL3_5x12.gif

You can (re-)compile by simply entering make at the command line.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL3_5x12.gif

And you can quickly run all the minimum required test cases (you probably want to do this only at a point where your program is at least mostly working) by simply entering make test at the command line.

Deliverables

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

Source files: SortedInt.hSortedInt.cppassign06.cpp, and Makefile.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

Test run results:

http://cs.txstate.edu/~lk04/2308/Assign/BulletL2_5x12.gif

You should at least test your implementation using the cases included in this  test input file . Be sure to check out this  explanation page  on how to use the file (and the utility of the Makefile mentioned above).

http://cs.txstate.edu/~lk04/2308/Assign/BulletL2_5x12.gif

NOTE

During grading, your program will typically be tested much more thoroughly than the minimum cases required above.

 NOTES:

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

Obviously, you will need to use separate compilation.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

Be sure to remove all irrelevant statements/comments in your code when submitting your work.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL2_5x12.gif

Be sure to totally remove (not just commenting out) the

cout << "... not implemented yet" << endl;

line and remove all irrelevant comments (like // dummy value returned) once you have written the code.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

Be sure to read/follow the instructions on what/how to submit posted  here .

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

If you discover anything that appears incorrect, please let me know (through email) as soon as possible.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

Be sure to check back often for updates and/or further information.

Assignment 6 Sample Test Input/Output Explanation 

To generate/present the results for an extensive number of test cases can be quite awkward for at least 2 reasons:

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

To manually generate and capture the test session can be quite tedious, time consuming, and boring.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

The output (which includes many menu listings) when printed consumes many pages (doesn't help in saving some trees, minimizing printer wear and tear, and avoiding attempts to staple pages together with undersized staplers, etc.).

We can avoid the above awkwardness by taking advantage of Linux's support for input/output redirection. The following describes how I did so:

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

I first created an input file that captures the input keystrokes I would enter had I run the program interactively. This resulted in a6test.in (one of the files in  Assignment 6 sample test input/output ).

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

I then uploaded a6test.in onto my Linux account, making sure that I placed it in the sub-directory where I had created my  Assignment 6  executable (which is named a6).

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

I then decided to have the corresponding output "redirected" to a file called a6test.out.

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

I then issued the following command at the Linux command prompt (note that input redirection is effected through < and output redirection through >):

./a6 auto < a6test.in > a6test.out

(Actually, I could have replaced auto with any other word and the result would still be the same.) 

 NOTES: 

http://cs.txstate.edu/~lk04/2308/Assign/BulletL1_7x15.gif

You would want to do the input/output redirection only when you are ready to do and capture the test cases one last time (and all at once) for submission. When you are still in the midst of testing/debugging your program, you would still want to do things the usual interactive way: 

./a6