All of the work in this project is my own!  I have not left copies of my code in public folders on university computers. I have not given any of this project to others. I will not give any portion of this project to others taking this class. I realize that the penalty for turning in work that is not my own can range from an "F" in the class to dismissal from Trinity University. 

                                                                                             Print Name  __________________________

                                                                                              Signature   __________________________


Dynamic Array I  Lab
Individual Assignment
40 Points


Set Netscape Margins [ Left = 1; Right = .2; Top = .6; Bottom = .6; Select Document Title, Location,  Page Number, Page Total Black Text l]


1]  Create  program DynamicArray1.cpp

2] Class Shall be called IntArray. The first array element filled shall be element 1. Do not use element 0 at any time in this program!
 

class IntArray
{
public: 
 IntArray(long int NewMax = 10);
 bool Empty (void);
 void Display(char Message[] = "", long int NoToDisplay = -999);
 void QuickAndDirtyDisplay (char Message[] = "");
 ~IntArray(void);
 void Initialize (void);
 void FillRandom(int NoToFill, int Low, int High);
 int Sum (void);
 int High (void);
 long double Average (void);
 int Low (void);
 void Stats(char Message[] = "");
private:
   long int
       Max,
       ActNo;
   int
       *Array;
};

3] The two displays written in class are listed below. The second was mailed to you. Be able to duplicate either without looking at the code.
 

void IntArray::QuickAndDirtyDisplay (char Message[])
{
long int
   Pos;

   if (strlen(Message) > 0)
      cout << Message << endl;
   if (ActNo == 0)
      cout << "\n Array Is Empty!\n\n";
   for (Pos = 1; Pos <= ActNo; Pos ++)
   {
      cout << setw(10) << Array[Pos];
      if (Pos % 10 == 0)
      cout << endl;
   }
   cout << endl << "ActNo = " << ActNo << "     Max = " << Max << "\n\n";
}


void IntArray::Display (char Message[], long int NoToDisplay)
{
long int
   Subscript;

   if (strlen(Message) > 0)
      cout << Message << endl;
   if (ActNo == 0)
      cout << "\n Array Is Empty!\n\n";
   if (NoToDisplay > 0)
   {
      if (NoToDisplay <= 0) 
         NoToDisplay = ActNo;
      if (NoToDisplay > Max)
         NoToDisplay = Max;

      for (Subscript = NoToDisplay; Subscript >= 1; Subscript --)
      {
         cout << " --------------------\n";
         cout << setw(6) << Subscript << " | " << setw(16) << Array[Subscript];
         cout << " |\n";
      }
      cout << " --------------------\n";
   }
   cout << " ActNo = " << ActNo << "     Max = " << Max << endl << endl << endl;
}

4]  With the exception of the Stats method, you know the functionality of all of the modules from lecture and previous labs. Output from the Stats module would be as follows: {It shall call QuickAndDirtyDisplay, High, Low, Sum, Average --- Make sure you include the dotted lines!}

------------------------------------------------------------------------
Stats for Module Nos Message
------------------------------------------------------------------------
Data: 
         1         2         1         3         1         1
ActNo = 6      Max = 100

Low    = 1
High   = 3
Sum    = 9
Average = 1.5
------------------------------------------------------------------------

5] Write a module, called TestInArray, which shall do the following:

  1. Create an IntArray object, called Exams; pass it no arguments.
  2. Create an IntArray object called Bowling; pass it integer value 30.
  3. Create an IntArray object, called Nos; pass it integer value 100;
  4. Create an IntArray object, called BadNos; pass it integer value -30.
  5. Evoke the Display method with Exams; pass it "Original Exams" and 5;
  6. Evoke the Display method with Bowling; pass it "Original Bowling" and 5;
  7. Evoke the Display method with Nos; pass it "Original Nos" and 5;
  8. Evoke the Display method with BadNos; pass it "Original BadNos" and 5;
  9. Completely fill the Exam object with random values in the range  80-100.
  10. Evoke the Display method with Exams; pass it "Exams[10] with values 80-100" and 5;
  11. Fill 70% of the Nos object with random values in the range  -5 to +5
  12. Evoke the QuickAndDirtyDisplay method with Nos; pass it "Nos [70%] with values -5 to +5".
  13. Attempt to fill 500 of the Bowling object with random values in the range 100-200.
  14. Evoke the QuickAndDirtyDisplay method with Bowling; pass it "Bowling [500] with values -5 to +5".
  15. Attempt to fill -3 of the BadNos object with random values in the range 1-10;
  16. Evoke the Display method with BadNos; pass it "BadNos[-3] with values 1-10"
  17. Initialize the Exam object.
  18. Evoke the Display method with Exams; pass it "Initialized Exams".
  19. Initialize the Nos object.
  20. Evoke the QuickAndDirtyDisplay method with Nos; pass it "Initialized Nos".
  21. Initialize the Nos object.
  22. Fill 10 of the Nos object with random values in the range 1-100
  23. Write a line of code that will display "High Nos        = 87" {if 87 is High Value};
  24. Write a line of code that will display "Low Nos         = 22" {if 22is LowValue};
  25. Write a line of code that will display "Average Nos = 52.3" {if 52.31 is the mean/arithmetic average};
  26. Write a line of code that will display "Sum Nos         = 523" {if 523 is the Sum};
  27. Write a line of code that will call/evoke the Stats module for object Nos. Pass the Message "Statistics for Nos Object"

6] Each and every program file that you turn in this semester shall contain a documentation block at the top. Document yours!
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
///                            xxxxxxx.cpp                                      //
///                                                                             //
/// Purpose    :                                                                //
///                                                                             //
/// Written By : Dr. Thomas E. Hicks                  Environment : Linux       //
/// Date       : 9/10/00                              Compiler    : g++         //
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////

7] The following line of code will execute your program and send the output to a file called Output.txt . Although you will not be able to see the prompts, enter the data specified above.

a.out > Output.txt

8] Start Windows 2000/NT/98/95

Use a Word Processor/Editor to print your programs. Set the left margin to 1 " and the right margin to .5". Make the font Courier 10 or New Courier 10. Print PrimeNo.cpp.  Print Output.txt.

9] Copy files DynamicArrays1.cpp and Output.txt to a floppy disk. Copy files DynamicArrays1.cpp and Output.txt to a second  floppy disk. Keep one of these disks as a backup.



10] Those Labs labeled "Individual Assignment" are to be done separately by each individual. Using a pen,  each individual is to print  his/her name at the top of this document in the space provided and sign it.  Those Labs labeled "Team Assignment" may be done as a team or individually. Using a pen,  each individual on the team is to print print his/her name at the top of this document in the space provided and sign it. Submit only one copy of team assignments!

Include the following in your wire-band binder:

A] Divider

B] Copy of this assignment sheet. Using an ink pen, print your name and sign this lab at the top.

C] Output.txt printout.

D] DynamicArrays1.cpp printout.

E] Disk containing the files.