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   __________________________

                                                                                             Print Name  __________________________

                                                                                              Signature   __________________________


Static Array System 0 Lab
Individual/Team (1-2 Persons) Assignment
20  Points


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


1] The main program is complete and shown below. Your job is to provide the missing modules.  Write the complete C++ Code. Call the Main Program   ArraySystem0.cpp
 
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//                                    ArraySystem1.cpp                                      //
//                                                                                          //
//  Purpose: Display, average, sum, and fill static integer array containers. Associated    //
//           with each array is a MAX (capacity) and an ActNo (how many filled at any       //
//           given moment in time. Always keep the ActNo accurate. Make sure that you       //
//           never exceed the boundaries of the array - even if you pass incorrect          //
//           NoToFill, NoToDisplay, etc. into functions.                                    //
//                                                                                          //
//  Written By: Dr. Thomas E. Hicks                                 Environment:Linux       //
//  Date: 9/17/01                                                   Compiler: C++           //
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
 

/////////////////////////////////////// Includes /////////////////////////////////////////////
# include <iostream.h>
# include <stdlib.h>
# include <time.h>
# include <iomanip.h>

/////////////////////////////////////// Defines //////////////////////////////////////////////
# define MAX_BOWLING   90
# define MAX_EXAMS     10
# define MAX_NOS       300
# define VALID         true 
# define INVALID       false

# define               UNIX
// # define            MAC
// # define            WINDOWS

///////////////////////////////////// Prototypes /////////////////////////////////////////////

void ClearScreen (void);
void Commercial (void);
void SetRandNoGeneratorSeed (void);
long int RandNo (long int Low, long int High);
void Delay (long int NoSeconds);

void DisplayIntArray (char Message[], int Array[], int NoToDisplay, int ActNo, int Max);
void RandomFillIntArray (int Array[], int & ActNo, int Low, int High, int NoToFill, int Max);
void InitializeIntArray (int Array[], int & ActNo, int Max);

main()
{
int
   BowlingScores[MAX_BOWLING],
   Exams [MAX_EXAMS], 
   Nos [MAX_NOS],

   ActNoBowling = 0,
   ActNoExams = 0,
   ActNoNos = 0;

   Commercial(); 

   SetRandNoGeneratorSeed(); 
   cout << "\n\n==================================================================================\n"; 
   cout << "==================================== 1 ===========================================\n"; 
   cout << "==================== Testing Display Values Are Garbage ==========================\n"; 
   cout << "==================================================================================\n\n"; 
   DisplayIntArray ("MAX_EXAMS Garbage Values Stored In Array Exams", Exams, MAX_EXAMS, ActNoExams, MAX_EXAMS); 
   DisplayIntArray ("15 Garbage Values Stored In Array Bowling", Bowling, MAX_BOWLING, ActNoBowling, MAX_BOWLING); 
   DisplayIntArray ("10 Garbage Values Stored In Array Nos", Nos, MAX_NOS, ActNoNos, MAX_NOS); 

/*
   cout << "\n\n==================================================================================\n"; 
   cout << "==================================== 2 ===========================================\n"; 
   cout << "============================= Testing Initialization =============================\n"; 
   cout << "==================================================================================\n\n"; 
   InitializeIntArray (Exams, ActNoExams, MAX_EXAMS); 
   InitializeIntArray (Bowling, ActNoBowling, MAX_BOWLING); 
   InitializeIntArray (Nos, ActNoNos, MAX_NOS); 

   DisplayIntArray ("Initialized Exams", Exams, 1000, ActNoExams, MAX_EXAMS); 
   DisplayIntArray ("Initialized Bowling", Bowling, 1000, ActNoBowling, MAX_BOWLING); 
   DisplayIntArray ("Initialized Nos", Nos, 1000, ActNoNos, MAX_NOS); 


   cout << "\n\n==================================================================================\n"; 
   cout << "==================================== 3 ===========================================\n"; 
   cout << "========================== Randomly Fill Arrays Half Full ========================\n"; 
   cout << "============================== Testing Display ==================================\n"; 
   cout << "==================================================================================\n\n"; 
   RandomFillIntArray (Exams, ActNoExams, 60, 100, 5, MAX_EXAMS); 
   RandomFillIntArray (Bowling, ActNoBowling, 0, 300, 15, MAX_BOWLING); 
   RandomFillIntArray (Nos, ActNoNos, 1, 10000, 500, MAX_NOS); 

   DisplayIntArray ("Half Filled Exams", Exams, ActNoExams, ActNoExams, MAX_EXAMS); 
   DisplayIntArray ("Half Filled Bowling", Bowling, ActNoBowling, ActNoBowling, MAX_BOWLING); 
   DisplayIntArray ("Half Filled Nos", Nos, ActNoNos, ActNoNos, MAX_NOS); 


   cout << "==================================================================================\n"; 
   cout << "==================================== 4 ===========================================\n"; 
   cout << "======================== Re-Initialize Arrays ====================================\n"; 
   cout << "===================== Testing Display [NoToDisplay Too Small] ====================\n"; 
   cout << "==================================================================================\n\n"; 
   InitializeIntArray (Exams, ActNoExams, MAX_EXAMS); 
   InitializeIntArray (Bowling, ActNoBowling, MAX_BOWLING); 
   InitializeIntArray (Nos, ActNoNos, MAX_NOS); 

   DisplayIntArray ("Initialized Exams", Exams, 3, ActNoExams, MAX_EXAMS); 
   DisplayIntArray ("Initialized Bowling", Bowling, 3, ActNoBowling, MAX_BOWLING); 
   DisplayIntArray ("Initialized Nos", Nos, 3, ActNoNos, MAX_NOS); 

   srand(5);
   cout << "\n\n==================================================================================\n"; 
   cout << "==================================== 5 ===========================================\n"; 
   cout << "======================= Randomly Fill Arrays Do Not Overflow =====================\n"; 
   cout << "============================== Testing Display ==================================\n"; 
   cout << "==================================================================================\n\n"; 
   RandomFillIntArray (Exams, ActNoExams, 60, 100, 1000, MAX_EXAMS); 
   RandomFillIntArray (Bowling, ActNoBowling, 0, 300, 1000, MAX_BOWLING); 
   RandomFillIntArray (Nos, ActNoNos, 1, 10000, 1000, MAX_NOS); 

   DisplayIntArray ("Overflowed Exams", Exams, ActNoExams, ActNoExams, MAX_EXAMS); 
   DisplayIntArray ("Overflowed Bowling", Bowling, ActNoBowling, ActNoBowling, MAX_BOWLING); 
   DisplayIntArray ("Overflowed Nos", Nos, ActNoNos, ActNoNos, MAX_NOS); 
*/
   return (0); 

//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//                                  InitializeIntArray                                      //
//                                                                                          //
//  Purpose: Set the NoToFill to be 0. Place A 0 in each and every element of the Array.    //
//                                                                                          //
//  Required Include Headers   : <stdlib.h>                                                 //
//  Required Support Modules   : None                                                       //
//  Recommended Support Modules: None                                                       //
//                                                                                          //
//  Written By: Dr. Thomas E. Hicks                                 Environment:Linux       //
//  Date: 9/17/01                                                   Compiler: C++           //
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
 
 

//You Do --> Leave two blank lines at the bottom of each function to separate it from others
  
 

//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//                                  RandomFillIntArray                                      //
//                                                                                          //
//  Purpose: If the NoToFill > Max, set the NoToFill to be the Max. If the NoToFill is      //
//           negative, set the NoToFill to be the Max. Place NoToFill Random Numbers        //
//           in the range <Low <--> High> into Array starting at element 0. Update the      //
//           ActNo.                                                                         //
//                                                                                          //
//  Required Include Headers   : <stdlib.h>                                                 //
//  Required Support Modules   : RandNo                                                     //
//  Recommended Support Modules: SetRandNoGeneratorSeed                                     //
//                                                                                          //
//  Written By: Dr. Thomas E. Hicks                                 Environment:Linux       //
//  Date: 9/17/01                                                   Compiler: C++           //
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
 
 

//You Do --> Leave two blank lines at the bottom of each function to separate it from others
  
 

//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//                                  DisplayIntArray                                         //
//                                                                                          //
//  Purpose: Display the Message and skip 2 lines. If the NoToDisplay is greater than the   //
//           Max, set the NoToDisplay to the Max. If The NoToDisplay is less than 0, set    //
//           the NoToDisplay to the Max. Provide a nice graphical view of the Array;        //
//           display the cells downward so that element 0 is at the bottom. Skip a line.    //
//           Display the ActNo and The Max. Skip three lines.                               //
//                                                                                          //
//  Required Include Headers   : <iostream.h>                                               //
//  Required Support Modules   : None                                                       //
//  Recommended Support Modules: ClearScreen                                                //
//                                                                                          //
//  Written By: Dr. Thomas E. Hicks                                 Environment:Linux       //
//  Date: 9/17/01                                                   Compiler: C++           //
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
void DisplayIntArray (char Message[], int Array[], int NoToDisplay, int ActNo, int Max)
{
int
   Counter;

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

//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//                                       ClearScreen                                        //
//                                                                                          //
//  Purpose: Clear the console window on a UNIX/Linux System.                               //
//                                                                                          //
//  Required Include Headers   : <stdlib.h>                                                 //
//  Required Support Modules   : none                                                       //
//  Recommended Support Modules: none                                                       //
//                                                                                          //
//  Written By: Dr. Thomas E. Hicks                                 Environment:Linux       //
//  Date: 9/17/01                                                   Compiler: C++           //
//                                                                                          //
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
void ClearScreen (void)
{
# ifdef UNIX           
    system ("clear");
# endif

# ifdef WINDOWS
 s   ystem ("cls");
# endif

}
 

//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//                                        Commercial                                        //
//                                                                                          //
//  Purpose: Display a program commercial somewhere near the center of a window.            //
//                                                                                          //
//  Required Include Headers   : <iostream.h>                                               //
//  Required Support Modules   : ClearScreen                                                //
//  Written By: Dr. Thomas E. Hicks                                 Environment:Linux       //
//  Date: 9/17/01                                                   Compiler: C++           //
//                                                                                          //
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
void Commercial (void)
{
   ClearScreen();
   cout << "                       Array Calculation System\n";
   cout << "                           Written by\n";
   cout << "                              ?????\n\n\n";
}
 

//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//                                SetRandNoGeneratorSeed                                    //
//                                                                                          //
//  Purpose: Use The Microprocessor Clock To Set The Seed Of The Random Number Generator.   //
//                                                                                          //
//  Required Include Headers: <time.h>                                                      //
//  Required Support Modules: none                                                          //
//  Recommended Support Modules: RandNo                                                     //
//                                                                                          //
//  Written By: Dr. Thomas E. Hicks                                 Environment:Linux       //
//  Date: 9/17/01                                                   Compiler: C++           //
//                                                                                          //
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
void SetRandNoGeneratorSeed (void)
{
   srand( (unsigned) time(NULL) );

 

//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//                                       RandNo                                             //
//                                                                                          //
//  Purpose: Explicitly Return A Random Number such that   Low <= RandNo <= High.           //
//                                                                                          //
//  Required Include Headers   : <stdlib.h>                                                 //
//  Recommended Support Modules: none                                                       //
//                                                                                          //
//  Written By: Dr. Thomas E. Hicks                                 Environment:Linux       //
//  Date: 9/17/01                                                   Compiler: C++           //
//                                                                                          //
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
 
 

//You Do --> Leave two blank lines at the bottom of each function to separate it from others
  
 

//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//                                         Delay                                            //
//                                                                                          //
//  Purpose: Simply stall or delay the computer for the desired number of seconds. This     //
//           module can be used to enable the user to read output on the console.           //
//                                                                                          //
//  Required Include Headers: <time.h>                                                      //
//  Required Support Modules: none                                                          //
//  Recommended Support none                                                                //
//                                                                                          //
//  Written By: Dr. Thomas E. Hicks                                 Environment:Linux       //
//  Date: 9/17/01                                                   Compiler: C++           //
//                                                                                          //
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
void Delay (long int NoSeconds)
{
time_t 
   CurrentTime;

   CurrentTime = time ((time_t *) NULL);
   while (time ((time_t *) NULL) < CurrentTime + time_t(NoSeconds))
   {
   }
}

2] Change the main program documentation to reflect that above.

3] Gradually phase in and test your modules one at a time. Gradually remove the comments from the main program until each and every module is well tested and complete.

4] Do the following when program is complete.

g++ ArraySystem0.cpp -o ArraySystem0  <-- Binary File Will Be Called ArraySystem0 - Not a.out
ArraySystem0 > Output.txt <-- Runs the program and dumps output into file Output.txt

5] Start Visual C++.  Set the left margin to 1 " and the right margin to .5". Make the font Courier 8 or New Courier 8. Print ArraySystem0.cpp and Output.txt



6] 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] Listings  ArraySystem0.cpp  and  Output.txt

D] Disk Containing  ArraySystem0.cpp  and  Output.txt

E] Divider

F] I have checked to make sure that others can not access this file in my UNIX account. 

                                          _________________________________ Sign Name!