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 Title  ______________________________________    Time Required = ______.____ Hrs.

                                    Signature   ______________________________________    (pledged)


IntArray II Lab
Individual Homework Assignment
15 Points

Tom-Hicks-Random-1000.txt

1] Write the code to create a text file called Tom-Hicks-Random-1000.txt (use your first and last name). This file is to contain 1,000 Random Numbers in the range 1-1,000.


Tom-Hicks-HW-8.c

1] Create main program Tom-WH-7. Paste the following code. Replace the utility file include with your own. It should compile.

//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                          Integer Array Functions                         //
//                                                                          //
//  Purpose : Dr. Thomas Hicks - PAD 1 Utility function collection.         //
//                                                                          //
//  Written By : Thomas E. Hicks         Environment : Linux                //
//  Date ......: xx/xx/xxxx              Compiler ...: gcc                  // 
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////// 

//////////////////////////////////////////////////////////////////////////////
//                                  Includes                                //
//////////////////////////////////////////////////////////////////////////////
# include "Tom-Hicks-Utility.h"

//////////////////////////////////////////////////////////////////////////////
//                              Add Prototypes                              //
//////////////////////////////////////////////////////////////////////////////
void FillIntArrayFromFile (int Array[], int * ActNo, int Max, char FileName[]);

//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                             FillIntArrayRandom                           //
//                                                                          //
//  Purpose : Begin Filling Array with data from the sequential text file.  //
//            the data on the file is one integer to a line. The number of  //
//            integers on the file will vary. Your program shall never      //
//            overflow the array. Do not use Array[0]. Begin with Array[1]  //
//            and then use Array[2] and then use Array[3] (etc). Stop if    //
//            full.                                                         //
//                                                                          //
//  Written By : Thomas E. Hicks         Envir onment : Linux               //
//  Date ......: xx/xx/xxxx               Compiler ...: gcc                 //
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void FillIntArrayFromFile (int Array[], int * ActNo, int Max, char FileName[])
{
int 
	Index;
	

}
 
TestHW7

1] Rename the old main to be TestHW7. See Below!

//////////////////////////////////////////////////////////////////////////////
//                                   TestHW7                                //
//////////////////////////////////////////////////////////////////////////////
void TestHW7(void);
{	
int 
	Bowling [MAX_BOWLING + 1 ],
	Exams [MAX_EXAMS +1 ];
int
	ActNoBowling,
	ActNoExams, 
	HighExams,
	LowExams,
	SumExams,
	HighBowling,
	LowBowling,
	SumBowling;
double
	AvrExams,
	AvrBowling;

	puts("\n=================================================================");
	puts("=========================== Section 1 ===========================");
	puts("=================================================================\n");

  	DisplayIntArray (Exams, ActNoExams, MAX_EXAMS, MAX_EXAMS, 
  		                 "\nUn-Initialized Exams");
  	InitializeIntArray(Exams, &ActNoExams, MAX_EXAMS);
  	DisplayIntArray (Exams, ActNoExams, MAX_EXAMS, MAX_EXAMS, 
  		                 "\nInitialized Exams");
  	FillIntArraySequence (Exams, &ActNoExams, MAX_EXAMS, -2, 5, 11);
  	DisplayIntArray (Exams, ActNoExams, MAX_EXAMS, MAX_EXAMS, 
  		                 "\n[-2,3,8,13, ...] <- Tried To Overflow Exams");
  	FillIntArrayRandom (Exams, &ActNoExams, MAX_EXAMS, 80, 100, 5);
  	DisplayIntArray (Exams, ActNoExams, MAX_EXAMS, 0, 
  		                 "\nValues [80-100] <- Tried To Overflow Exams");
  	SumExams = SumIntArray (Exams, ActNoExams);
  	printf("SumExams = %d\n", SumExams);
  
  	HighExams = HighIntArray (Exams, ActNoExams);
  	printf("HighExams = %d\n", HighExams);

  	LowExams = LowIntArray (Exams, ActNoExams);
  	printf("LowExams = %d\n", LowExams);

  	AvrExams = AvrIntArray (Exams, ActNoExams);
  	printf("AvrExams = %lf\n\n", AvrExams);

	Pause();
	puts("\n=================================================================");
	puts("=========================== Section 2 ===========================");
	puts("=================================================================\n");

  	InitializeIntArray(Bowling, &ActNoBowling, MAX_BOWLING);
  	DisplayIntArray (Bowling, ActNoBowling, MAX_BOWLING, -1,
  		                 "Checking Bowling Display - NoToDisplay is negative!");
	Pause();

  	FillIntArrayRandom (Bowling, &ActNoBowling, MAX_BOWLING, 100, 300, 99);
  	DisplayIntArray (Bowling, ActNoBowling, MAX_BOWLING, 0, 
  		                 "\n999 Bowling Scores");
  	SumExams = SumIntArray (Exams, ActNoExams);
  	printf("SumExams = %d\n", SumExams);

  	HighBowling = HighIntArray (Bowling, ActNoBowling);
  	printf("HighBowling = %d\n", HighBowling);

  	LowBowling = LowIntArray (Bowling, ActNoBowling);
  	printf("LowBowling = %d\n", LowBowling);

  	AvrBowling = AvrIntArray (Bowling, ActNoBowling);
  	printf("AvrBowling = %.3lf\n\n", AvrBowling);

	Pause();
	puts("\n=================================================================");
	puts("=========================== Section 3 ===========================");
	puts("========   You may choose to skip this, but if you do,     ======");
	puts("========        the maximum grade will be 85% (-15%).      ======");
	puts("=================================================================\n");

  	InitializeIntArray(Exams, &ActNoExams, MAX_EXAMS);
  	DisplayIntArray (Exams, ActNoExams, MAX_EXAMS, MAX_EXAMS, 
  		                 "\nInitialized Exams");
	Pause();

  	InitializeIntArray(Exams, &ActNoExams, MAX_EXAMS);
  	DisplayIntArray (Exams, ActNoExams, MAX_EXAMS, 0,"Exams:");

//   Enter 3 Values and Exit
  	AppendIntArrayGetInt ("Enter Exam", Exams, &ActNoExams, MAX_EXAMS, 
  							50,100);
  	DisplayIntArray (Exams, ActNoExams, MAX_EXAMS, 0, 
  	                 "We Have Appended The First 3 Exams");
	Pause();


//   Enter 1 Value and Exit
  	AppendIntArrayGetInt ("Enter Exam", Exams, &ActNoExams, MAX_EXAMS, 
  							50,100);
  	DisplayIntArray (Exams, ActNoExams, MAX_EXAMS, 0, 
  		             "We Have Appended4 Exa ms");
	Pause();


//   Enter No Values - Hit Carriage Return
  	AppendIntArrayGetInt ("Enter Exam", Exams, &ActNoExams, MAX_EXAMS, 
  							50,100);
  	DisplayIntArray (Exams, ActNoExams, MAX_EXAMS, 0, 
  		             "We Have Still Appended 4 Exams");
	Pause();


//   Attempt To Enter 4 More Exams - Print full message after 2 more and Exit
  	AppendIntArrayGetInt ("Enter Exam", Exams, &ActNoExams, MAX_EXAMS, 
  							50,100);
  	DisplayIntArray (Exams, ActNoExams, MAX_EXAMS, 0, 
  		             "We Have Appended 6 Exams");
	Pause();


 //  Attempt To Enter 4 More Exams - Print full message after 2 more and Exit
  	AppendIntArrayGetInt ("Enter Exam", Exams, &ActNoExams, MAX_EXAMS, 
  							50,100);
  	DisplayIntArray (Exams, ActNoExams, MAX_EXAMS, 0, 
  		             "We Still Have Appended 6 Exams");
	Pause();
}
 
Write Function Main

1] Copy and paste the following into main:

  ////////////////////////////////////////////////////////////////////////////
//                                    Defines                               //
//////////////////////////////////////////////////////////////////////////////
# define MAX_BOWLING 1005
# define MAX_EXAMS 6

//////////////////////////////////////////////////////////////////////////////
//                                      main                                //
//////////////////////////////////////////////////////////////////////////////
int main (int argc, char * argv[])
{	
int 
	Bowling [MAX_BOWLING + 1 ],
	Exams [MAX_EXAMS +1 ];
int
	ActNoBowling,
	ActNoExams;
double
	AvrExams,
	AvrBowling;

	InitializeIntArray(Exams, &ActNoExams, MAX_EXAMS);
	FillIntArrayFromFile (Exams, &ActNoExams, MAX_EXAMS, "Tom-Hicks-Random-1000.txt");
 	DisplayIntArray (Exams, ActNoExams, MAX_EXAMS, MAX_EXAMS, 
 		                 "\nExams: File Filled");	
	Pause();
	InitializeIntArray(Bowling, &ActNoBowling, MAX_BOWLING);
	FillIntArrayFromFile (Bowling, &ActNoBowling, MAX_BOWLING, "Tom-Hicks-Random-1000.txt");
 	DisplayIntArray (Bowling, ActNoBowling, MAX_BOWLING, ActNoBowling, 
 		                 "\n Bowling: File Filled");
	Pause();
	return 0;
}

			

Copy Files

 
1] Copy file Tom-HW8.c ========================>  to /users/thicks/hw1320/hw8

2] Copy file Tom-Hicks- Utility.h ==============>  to /users/thicks/hw1320/hw8

3] Copy file Tom-Hicks-Random-1000.txt =====>  to /users/thicks/hw1320/hw8


What To Turn In

1] Signed copy of page 1 of this Lab.

2] Printed copy of only Function FillIntArrayFromFile and the documentation that goes with it.

3] Nothing will be graded until you copy the file into the /users/thicks/hw1320 directory.

4] Nothing will be graded until this lab form is submitted.  Staple the pages. Fold the lab Horizontally (like a hot dog) and write your name nice and large on the outside.  Place it on the professor desk before the beginning of lecture on the day it is due. All assignments are due the next class period unless otherwise designated on the schedule page.