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 I Lab
Individual Homework Assignment
30 Points
 

Utility-Tom-Hicks.h

1] Create file Utility-Tom-Hicks.h (use your first and last name)

2] Copy and paste the code below into this file. You have written all of the functions outlined in this file; copy them into this file. Please use the comments below; they will print nicely on our printers.

//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                           Integer-Array Functions I                      //
//                                                                          //
//  Purpose : Dr. Thomas Hicks - Generic Utility Functions for Integer      //
//            Arrays.                                                       //
//                                                                          //
//  Written By : Thomas E. Hicks         Environment : Linux                //
//  Date ......: xx/xx/xxxx              Compiler ...: gcc                  // 
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////// 

//////////////////////////////////////////////////////////////////////////////
//                             Standard Includes                            //
//////////////////////////////////////////////////////////////////////////////
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <stdbool.h>
# include <ctype.h>

//////////////////////////////////////////////////////////////////////////////
//                                 Prototypes                               //
//////////////////////////////////////////////////////////////////////////////
void ClearScreen();
void StdinFlush(void);
void Pause();

bool GetString(char Prompt[], char String[], long int MaxChar, bool Clear);
bool GetInt (char Prompt[], int * Int, int Low, int High, bool Clear);
bool ValidFloatStr(char String[]);
bool GetFloat (char Prompt[], float * Float, float Low, float High, bool Clear);

void itoa (char String[], int No);
void ftoa (char String[], float No);

char UpChar (char Ch);
char LowChar(char Ch);
void UpperStr (char String[]);
void LowerStr (char String[]);
long int RandNo (long int Low, long int High);
void TestUtility();

//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                                 ClearScreen                              //
//                                                                          //
//  Purpose : Clear the Linux terminal window.                              //
//                                                                          //
//  Written By : Thomas E. Hicks         Environment : Linux                //
//  Date ......: xx/xx/xxxx              Compiler ...: gcc                  //
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void ClearScreen(void)
{
	system("clear");
}


//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                                StdinFlush                                //
//                                                                          //
// Purpose : This utility, to be used immediately after every scanf, is     //
//           used to flush the standard input buffer.                       //
//                                                                          //
//  Written By : Thomas E. Hicks         Environment : Linux                //
//  Date ......: xx/xx/xxxx              Compiler ...: gcc                  //
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void StdinFlush(void)
{
char
	Junk[100];

	gets(Junk);
}

//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                                 Pause                                    //
//                                                                          //
//  Purpose : Simply Delay the system so that the user can read what's on    //
//            the terminal window.                                          //
//                                                                          //
//  Written By : Thomas E. Hicks         Environment : Linux                //
//  Date ......: xx/xx/xxxx              Compiler ...: gcc                  //
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void Pause(void)
{
char
	TempString[200];

	printf("\n-------------- [Hit ENTER Key To Continue!] -------------- ");
 	gets (TempString);
	printf("\n");
}

//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                                 GetString                                //
//                                                                          //
//  Purpose : (1) If Clear is true, then clear the terminal window;         //
//            otherwise don't.                                              //
//                                                                          //
//            (2) Print the prompt; to the right of the prompt add          //
//            [Hit ENTER Key To Exit!]. For the function call:              //
//            GetString("Enter Name", Name, 50,false)  the user should see  // 
//                  ==> Enter Name [Hit ENTER Key To Exit!] :               //
//                                                                          //
//            (3) Declare char TempString[200];                             //
//            It is now time for the user to respond to the prompt. Use     //
//            function gets to fill the string container called TempString. //
//                                                                          //
//            (4) If the USER simply hits the ENTER key, return false.      //
//                                                                          //
//            (5) Check to see if the user entered too many characters      //
//                (more than 29 for the example above)                      //
//              "The info you have just entered is too big!\n"              //
//              "Your answer may be no more than 49 characters in length\n" //
//              "Please Try Again!\n\n\n"                                   //
//              Return to step (2) and repeat all of the steps.             //
//                                                                          //
//            (6) Transfer the contents of TempString to String (after all  //
//                you now know that it will fit)                            //
//                                                                          //
//            (7) Return true.                                              //
//                                                                          //
//                                                                          //
//  Written By : Thomas E. Hicks         Environment : Linux                //
//  Date ......: xx/xx/xxxx              Compiler ...: gcc                  // 
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////// 



//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                                 GetInt                                   //
//                                                                          //
//  Purpose : (1) If Clear is true, then clear the terminal window;         //
//            otherwise don't.                                              //
//                                                                          //
//            (2) Print the prompt; to the right of the prompt add          //
//            [Hit ENTER Key To Exit!]. For the function call:              // 
//            GetInt("Enter Exam 2", Exam2, 0,100,false)                    // 
//            the user should see                                           //
//                    ==> Enter Exam 2 [Hit ENTER Key To Exit!] :           //
//                                                                          //
//            (3) Declare char TempString[100];                             //
//            It is now time for the user to respond to the prompt. Use     //
//            function gets to fill the string container called TempString. //
//                                                                          //
//            (4) If the USER simply hits the ENTER key, return false.      //
//                                                                          //
//            (5) Check to see if the USER enters a non-numerical value     //
//                (maybe use atoi and our own itoa to verify that the       //
//                 number is indeed numeric)                                //
//                                                                          //
//                 gets(IntStr) User enters "1234"     IntStr = "1234"      //
//                 TempInt = atoi(TempString)          TempInt = 1234       //
//                 itoa(TempString, TempInt);          TempString = "1234"  //
//                 strcmp(IntStr,TempString) = 0       Therefore Number OK  //
//                                                                          //
//                 gets(IntStr) User enters "12A4"     IntStr = "12A4"      //
//                 TempInt = atoi(TempString)          TempInt = 12         //
//                 itoa(TempString, TempInt);          TempString = "12  "  //
//                 strcmp(IntStr,TempString) != 0      Therefore Number !OK //
//                                                                          //
//                 If the number is not ok print an error message:          //
//                    "\n\nYou Have Entered Invalid Data!\n"                //
//                     Return to step (2) and repeat all of the steps.      //
//                     Do not ever use a GoTo command!                      //
//                                                                          //
//            (6) The number is valid thus far. Check to see if the TempInt //
//                is less than the Low.                                     //
//                                                                          //
//                 If the number is not ok print an error message:          //
//                    "\n\nYour Entry Is Too High - Enter A ");             //
//                    "Value [0 - 100]!\n\n"                                //
//                     Return to step (2) and repeat all of the steps.      //
//                     Do not ever use a GoTo command!                      //
//                                                                          //
//            (7) The number is valid thus far. Check to see if the TempInt //
//                is greater than the High.                                 //
//                                                                          //
//                 If the number is not ok print an error message:          //
//                    "\n\nYour Entry Is Too Low - Enter A ");              //
//                    "Value [0 - 100]!\n\n"                                //
//                     Return to step (2) and repeat all of the steps.      //
//                     Do not ever use a GoTo command!                      //
//                                                                          //
//            (8) Transfer the contents of TempInt to *Int (after all       //
//                you now know that it is the correct datatype and within   //
//                the acceptable range.                                     //
//                                                                          //
//            (7) Return true.                                              //
//                                                                          //
//                                                                          //
//  Written By : Thomas E. Hicks         Environment : Linux                //
//  Date ......: xx/xx/xxxx              Compiler ...: gcc                  // 
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////// 



//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                               ValidFloatStr                              //
//                                                                          //
//  Purpose : Explicitly return true if the String is a valid Float.        //
//            return false.                                                 //
//                                                                          //
//  Written By : Thomas E. Hicks         Environment : Linux                //
//  Date ......: xx/xx/xxxx              Compiler ...: gcc                  // 
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////// 
bool ValidFloatStr(char String[])
{
bool
	Valid = true;
int
	Pos,
	NoDecimalPoints = 0;

// First character must be + or - or digit
	if ((String[0] != '+') && (String[0] != '-') && (isdigit(String[0]) == 0) )
		return (false);

// Must only be one decimal point in the number
	for (Pos = 0; Pos < strlen(String); Pos ++)
		if (String[Pos] == '.')
			NoDecimalPoints++;
	if (NoDecimalPoints > 1)
		return (false);

// Characters 2, 3, 4, ... must be either a digit or a decimal point

	for (Pos = 1; Pos < strlen(String); Pos ++)
		if (  (String[Pos] != '.') && (isdigit(String[Pos]) == 0)) 
			return (false);

	return(Valid);
}


//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                                 GetFloat                                 //
//                                                                          //
//  Assumptions : You may assume that our user must enter the decimal point //
//                You may assume use enters no more than four digits to     //
//                right of the decimal point.                               //
//  Purpose : (1) If Clear is true, then clear the terminal window;         //
//            otherwise don't.                                              //
//                                                                          //
//            (2) Print the prompt; to the right of the prompt add          //
//            [Hit ENTER Key To Exit!]. For the function call:              // 
//            GetFloat("Enter Exam 2", Exam2, 0,100,false)                  // 
//            the user should see                                           //
//                   ==> Enter Exam 2 [Hit ENTER Key To Exit!] :            //
//                                                                          //
//            (3) Declare char TempString[100];                             //
//            It is now time for the user to respond to the prompt. Use     //
//            function gets to fill the string container called TempString. //
//                                                                          //
//            (4) If the USER simply hits the ENTER key, return false.      //
//                                                                          //
//            (5) Check to see if the USER enters a valid Float string.     //
//                                                                          //
//                Use the ValidFloatStr(FloatStr) function I have provided. //
//                If the number is not ok print an error message:           //
//                    "\n\nYou Have Entered Invalid Data!\n"                //
//                     Return to step (2) and repeat all of the steps.      //
//                     Do not ever use a GoTo command!                      //
//                                                                          //
//            (6) The number is valid thus far. Check to see if the         //
//                TempFloat is less than the Low.                           //
//                                                                          //
//                 If the number is not ok print an error message:          //
//                    "\n\nYour Entry Is Too High - Enter A ");             //
//                    "Value [0 - 100]!\n\n"                                //
//                     Return to step (2) and repeat all of the steps.      //
//                     Do not ever use a GoTo command!                      //
//                                                                          //
//            (7) The number is valid thus far. Check to see if the         //
//                TempFloat is greater than the High.                       //
//                                                                          //
//                 If the number is not ok print an error message:          //
//                    "\n\nYour Entry Is Too High - Enter A ");             //
//                    "Value [0 - 100]!\n\n"                                //
//                     Return to step (2) and repeat all of the steps.      //
//                     Do not ever use a GoTo command!                      //
//                                                                          //
//            (8) Transfer the contents of TempFloat to *Float (after all   //
//                you now know that it is the correct datatype and within   //
//                the acceptable range.                                     //
//                                                                          //
//            (7) Return true.                                              //
//                                                                          //
//                                                                          //
//  Written By : Thomas E. Hicks         Environment : Linux                //
//  Date ......: xx/xx/xxxx              Compiler ...: gcc                  // 
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////// 


//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                                  itoa                                    //
//                                                                          //
//  Purpose : Fill String with the integer equivalent of No.                //
//                                                                          //
//  Written By : Thomas E. Hicks         Environment : Linux                //
//  Date ......: xx/xx/xxxx              Compiler ...: gcc                  // 
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void itoa (char String[], int No)
{
	sprintf (String, "%d", No);
}
	
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                                  ftoa                                    //
//                                                                          //
//  Purpose : Fill String with the float equivalent of No.                  //
//                                                                          //
//  Written By : Thomas E. Hicks         Environment : Linux                //
//  Date ......: xx/xx/xxxx              Compiler ...: gcc                  // 
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////// 
void ftoa (char String[], float No)
{
	sprintf (String, "%f", No);
}


//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                                   LowChar                                //
//                                                                          //
//  Purpose : Explicitly return the lower case character. Character T       //
//            becomes t & character X becomes x. Only capital letters are   //
//            changed; all others are simply returned as is.                //
//                                                                          //
//  Written By : Thomas E. Hicks         Environment : Linux                //
//  Date ......: xx/xx/xxxx              Compiler ...: gcc                  // 
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                                   UpChar                                 //
//                                                                          //
//  Purpose : Explicitly return the upper case character. Character t       //
//            becomes T & character x becomes X. Only lower letters are     //
//            changed; all others are simply returned as is.                //
//                                                                          //
//  Written By : Thomas E. Hicks         Environment : Linux                //
//  Date ......: xx/xx/xxxx              Compiler ...: gcc                  // 
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////// 

//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                                   LowerStr                               //
//                                                                          //
//  Purpose : Convert String[] to all lower case characters.                //
//            LowerStr("tOm HiCKs") becomes string tom hicks                //
//                                                                          //
//  Written By : Thomas E. Hicks         Environment : Linux                //
//  Date ......: xx/xx/xxxx              Compiler ...: gcc                  // 
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////// 


//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                                     UpperStr                             //
//                                                                          //
// Purpose : Convert String[] to all upper case characters.                 //
//            UpperStr("tOm HiCKs") becomes string TOM HICKS                //
//                                                                          //
//  Written By : Thomas E. Hicks         Environment : Linux                //
//  Date ......: xx/xx/xxxx              Compiler ...: gcc                  // 
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////// 


//////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////// 
//                                   RandNo                                 //
//                                                                          //
//  Purpose : Explicitly return a random number in the range [Low -> High]. //
//                                                                          //
//                                                                          //
//  Written By : Thomas E. Hicks         Environment : Linux                //
//  Date ......: xx/xx/xxxx              Compiler ...: gcc                  // 
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////// 


//////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////// 
//                                TestUtility                               //
//                                                                          //
//  Purpose : Test some of the early utility functions.                     //
//                                                                          //
//  Written By : Thomas E. Hicks         Environment : Linux                //
//  Date ......: xx/xx/xxxx              Compiler ...: gcc                  // 
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////// 
void TestUtility()
{
char
	Name[12];
int
	Age,
	Ex1,
	Ex2;
float
	SemAvr;

    puts ("\n==================== Start Of TestGets ========================\n");

	if ( (GetString("Enter Name", Name, 12, true))           &&
		 (GetInt("Enter Age", &Age, 1, 30, false))           &&
		 (GetInt("Enter Exam 1 Grade", &Ex1, 0, 100, false)) &&
		 (GetInt("Enter Exam 2 Grade", &Ex2, 0, 100, false)) &&
		 (GetFloat("Enter Semester Average", &SemAvr, 0.0, 100.0, false)) )
	{
		printf("\n\n");
		printf("Name ....= %s\n", Name);
		printf("Age .....= %d\n", Age);
		printf("Ex1 .....= %d\n", Ex1);
		printf("Ex2 .....= %d\n", Ex2);
		printf("SemAvr ..= %f\n", SemAvr);

	}
	else
		puts ("You Chose Not To Provide All Of Our Information!");

	
	puts ("\n==================== End Of TestGets =====================\n");
}

3] I encourage you to call TestUtility() from main to make sure that your functions are still working correctly.

4] Make sure that all documentation has a date and your name.


Tom-HW-7

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"

//////////////////////////////////////////////////////////////////////////////
//                                 Prototypes                               //
//////////////////////////////////////////////////////////////////////////////
void DisplayIntArray (int Array[], int ActNo, int Max, int NoToDisplay, 
						  char Message[]);
void InitializeIntArray(int Array[], int * ActNo, int Max);
void FillIntArrayRandom (int Array[], int * ActNo, int Max, int Low, 
							 int High, int NoToFill);
void FillIntArraySequence (int Array[], int * ActNo, int Max, int StartingNo, 
							 int Multiple, int NoToFill);

int SumIntArray (int Array[], int ActNo);
int HighIntArray (int Array[], int ActNo);
int LowIntArray (int Array[], int ActNo);
double AvrIntArray (int Array[], int ActNo);
void AppendIntArrayGetInt (char Prompt[], int Array[], int * ActNo, int Max, 
							int Low, int High);

//////////////////////////////////////////////////////////////////////////////
//                                    Defines                               //
//////////////////////////////////////////////////////////////////////////////
# define MAX_BOWLING 100
# define MAX_EXAMS 6

//////////////////////////////////////////////////////////////////////////////
//                                     main                                 //
//////////////////////////////////////////////////////////////////////////////
int main (int argc, char * argv[])
{	
int 
	Bowling [MAX_BOWLING + 1 ],
	Exams [MAX_EXAMS +1 ];
int
	ActNoBowling,
	ActNoExams = 0, 
	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();
	return 0;
	Pause();
	return 0;
}

//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                               DisplayIntArray                            //
//                                                                          //
//  Purpose : Graphically represent the Array. Suppose the data in the      //
//            the Array is 5, 10, and 15 and the max is 6; we are going     //
//            to use Array[0]. The function call:                           //
//       ==> DispalyIntArray(Bowling, ActNoBowling, MAX_BOWLING,            //
//                           ActNoBowling, "Display Bowling Array Data"     //
//                                                                          //
//     Display Bowling Array Data                                           //
//                |--------------------|                                    //
//              3 |                 15 |                                    //
//                |--------------------|                                    //
//              2 |                 10 |                                    //
//                |--------------------|                                    //
//              1 |                  5 |                                    //
//                |--------------------|                                    //
//                 ActNo = 3   Max = 8                                      //
//                                                                          //
//       ==> DispalyIntArray(Bowling, ActNoBowling, -2,                     //
//                           MAX_BOWLING, "Display Bowling Array Container" //
//                                                                          //
//     Display Bowling Array Container                                      //
//                |--------------------|                                    //
//              6 |         -120444323 |                                    //
//                |--------------------|                                    //
//              5 |         -120444323 |                                    //
//                |--------------------|                                    //
//              4 |         -120444323 |                                    //
//                |--------------------|                                    //
//              3 |                 15 |                                    //
//                |--------------------|                                    //
//              2 |                 10 |                                    //
//                |--------------------|                                    //
//              1 |                  5 |                                    //
//                |--------------------|                                    //
//                 ActNo = 3   Max = 8                                      //
//                                                                          //
//                                                                          //
//      If we display more than ActNo, we may well have some uninitialized  //
//      garbage in our display.  If the NoToDisplay is negative display     //
//      all of the elements in the Array. If the NoToDisplay = 0 then       //
//      display only the valid data [1-ActNo].                              //
//                                                                          //
//  Written By : Thomas E. Hicks         Envir onment : Linux               //
//  Date ......: xx/xx/xxxx               Compiler ...: gcc                 //
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void DisplayIntArray (int Array[], int ActNo, int Max, int NoToDisplay, 
						  char Message[])
{
int 
	Index;

	if (NoToDisplay < 0)
		NoToDisplay = Max;
	if (NoToDisplay == 0)
		NoToDisplay = ActNo;

	if (strlen(Message) > 0) 
		puts(Message);
	for (Index = NoToDisplay; Index >= 1; Index--)
	{
		puts("      |----------------------|   ");		
		printf("%5d | %20d | \n", Index, Array[Index]);
		
	}
	if (NoToDisplay > 0)
		puts("      |----------------------|   ");
	else
		puts("\nThe Array Is Empty\n");
	printf("       The Max = %d      Act No = %d\n\n", Max, ActNo);
}


//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                             InitializeIntArray                           //
//                                                                          //
//  Purpose : Completely fill the Array with 0. Set the ActNo to 0. The     //
//            function call                                                 //
//            ==> InitializeIntArray(Bowling, &ActNoBowling)                //
//                                                                          //
//     No matter what Bowling originally had, it will now contain           //
//                |--------------------|                                    //
//              8 |                  0 |                                    //
//                |--------------------|                                    //
//              7 |                  0 |                                    //
//                |--------------------|                                    //
//              6 |                  0 |                                    //
//                |--------------------|                                    //
//              5 |                  0 |                                    //
//                |--------------------|                                    //
//              4 |                  0 |                                    //
//                |--------------------|                                    //
//              3 |                  0 |                                    //
//                |--------------------|                                    //
//              2 |                  0 |                                    //
//                |--------------------|                                    //
//              1 |                  0 |                                    //
//                |--------------------|                                    //
//                 ActNo = 0   Max = 8                                      //
//                                                                          //
//  Written By : Thomas E. Hicks         Envir onment : Linux               //
//  Date ......: xx/xx/xxxx               Compiler ...: gcc                 //
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void InitializeIntArray(int Array[], int * ActNo, int Max)
{
int 
	Index;


}


//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                            FillIntArraySequence                          //
//                                                                          //
//  Purpose : Begin Filling Array with random numbers in the range          //
//            [Low -> High]. Do not use Array[0]. Begin with Array[1] and   //
//            then use Array[2] and then use Array[3] (etc)                 //
//  ==> FillIntArraySequence(Bowling, &ActNoBowling, MAX_BOWLING, 10, 7, 3) //
//            will attempt to place 3 random bowling scores, in the range   //
//            [0-300], into Array. Never Overflow the Array; stop when      //
//            full. Always make sure that ActNo is accurate.                //
//                                                                          //
//     When done, the array might contain the following                     //
//                |--------------------|                                    //
//              3 |                 24 |                                    //
//                |--------------------|                                    //
//              2 |                 17 |                                    //
//                |--------------------|                                    //
//              1 |                 10 |                                    //
//                |--------------------|                                    //
//                 ActNo = 3   Max = 8                                      //
//                                                                          //
//  Written By : Thomas E. Hicks         Envir onment : Linux               //
//  Date ......: xx/xx/xxxx               Compiler ...: gcc                 //
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void FillIntArraySequence (int Array[], int * ActNo, int Max, int StartingNo,
                           int Multiple, int NoToFill)
{
int 
	Index;
	

}


//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                             FillIntArrayRandom                           //
//                                                                          //
//  Purpose : Begin Filling Array with random numbers in the range          //
//            [Low -> High]. Do not use Array[0]. Begin with Array[1] and   //
//            then use Array[2] and then use Array[3] (etc)                 //
//   ==> FillIntArrayRandom(Bowling, &ActNoBowling, MAX_BOWLING, 0, 300, 3) //
//            will attempt to place 3 random bowling scores, in the range   //
//            [0-300], into Array. Never Overflow the Array; stop when      //
//            full. Always make sure that ActNo is accurate.                //
//                                                                          //
//     When done, the array might contain the following                     //
//                |--------------------|                                    //
//              3 |                 32 |                                    //
//                |--------------------|                                    //
//              2 |                191 |                                    //
//                |--------------------|                                    //
//              1 |                150 |                                    //
//                |--------------------|                                    //
//                 ActNo = 3   Max = 8                                      //
//                                                                          //
//  Written By : Thomas E. Hicks         Envir onment : Linux               //
//  Date ......: xx/xx/xxxx               Compiler ...: gcc                 //
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void FillIntArrayRandom (int Array[], int * ActNo, int Max, int Low, 
							 int High, int NoToFill)
{
int 
	Index;
	

}

//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                                 SumIntArray                              //
//                                                                          //
//  Purpose : Explicitly return the sum of the elements in the array. If the //
//            array is empty, return 0.                                     //
//                                                                          //
//     Suppose the Array has the following:                                 //
//                |--------------------|                                    //
//              3 |                 31 |                                    //
//                |--------------------|                                    //
//              2 |                191 |                                    //
//                |--------------------|                                    //
//              1 |                150 |                                    //
//                |--------------------|                                    //
//                 ActNo = 3   Max = 8                                      //
//                                                                          //
//  Returned Value =    372                                                 //
//                                                                          //
//  Written By : Thomas E. Hicks         Envir onment : Linux               //
//  Date ......: xx/xx/xxxx               Compiler ...: gcc                 //
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
int SumIntArray (int Array[], int ActNo)
{
int 
	Index,
	Sum = 0;


	return (Sum);
}


//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                                HighIntArray                              //
//                                                                          //
//  Purpose : Explicitly return the largest of the elements in the array.   //
//            If the array is empty, return 0.                              //
//                                                                          //
//     Suppose the Array has the following:                                 //
//                |--------------------|                                    //
//              3 |                 31 |                                    //
//                |--------------------|                                    //
//              2 |                191 |                                    //
//                |--------------------|                                    //
//              1 |                150 |                                    //
//                |--------------------|                                    //
//                 ActNo = 3   Max = 8                                      //
//                                                                          //
//  Returned Value =    191                                                 //
//                                                                          //
//  Written By : Thomas E. Hicks         Envir onment : Linux               //
//  Date ......: xx/xx/xxxx               Compiler ...: gcc                 //
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
int HighIntArray (int Array[], int ActNo)
{
int 
	Index,
	HighValue = 0,
	Sum = 0;


	return (HighValue);
}


//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                                LowIntArray                               //
//                                                                          //
//  Purpose : Explicitly return the smallest of the elements in the array.  //
//            If the array is empty, return 0.                              //
//                                                                          //
//     Suppose the Array has the following:                                 //
//                |--------------------|                                    //
//              3 |                 31 |                                    //
//                |--------------------|                                    //
//              2 |                191 |                                    //
//                |--------------------|                                    //
//              1 |                150 |                                    //
//                |--------------------|                                    //
//                 ActNo = 3   Max = 8                                      //
//                                                                          //
//  Returned Value =   31                                                   //
//                                                                          //
//  Written By : Thomas E. Hicks         Envir onment : Linux               //
//  Date ......: xx/xx/xxxx               Compiler ...: gcc                 //
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
int LowIntArray (int Array[], int ActNo)
{
int 
	Index,
	LowValue = 0,
	Sum = 0;


	return (LowValue);
}



//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                                AvrIntArray                               //
//                                                                          //
//  Purpose : Explicitly return the arithmetic average of the elements in   //
//            the array.                                                    //
//                                                                          //
//     Suppose the Array has the following:                                 //
//                |--------------------|                                    //
//              4 |                 52 |                                    //
//                |--------------------|                                    //
//              3 |                 40 |                                    //
//                |--------------------|                                    //
//              2 |                 30 |                                    //
//                |--------------------|                                    //
//              1 |                 20 |                                    //
//                |--------------------|                                    //
//                 ActNo = 4   Max = 8                                      //
//                                                                          //
//  Returned Value =   35.500                                               //
//                                                                          //
//  Written By : Thomas E. Hicks         Envir onment : Linux               //
//  Date ......: xx/xx/xxxx               Compiler ...: gcc                 //
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
double AvrIntArray (int Array[], int ActNo)
{
	return (1.11);
}

//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                            AppendIntArrayGetInt                          //
//                                                                          //
//  Purpose : If full, or when full, display message:                       //
//            "\n\nWe are sorry, but the container is full; you may enter   //
//             no more data!\n\n\n"                                         //
//                                                                          //
//            Use your GetInt function. Continue to prompt the user for     //
//            valid integers (within the acceptable range) until either     //
//            the user exits with the ENTER key or the container is full.   //
//                                                                          //
//     Suppose the Array has the following:                                 //
//                |--------------------|                                    //
//              3 |                 31 |                                    //
//                |--------------------|                                    //
//              2 |                191 |                                    //
//                |--------------------|                                    //
//              1 |                150 |                                    //
//                |--------------------|                                    //
//                 ActNo = 3   Max = 8                                      //
//                                                                          //
//             For the function call:                                       //
// ==> AppendIntArrayGetInt ("Enter Exam", Exams, &ActNoExams, MAX_EXAMS,   //
//                           50,100);                                       //
//             the GetInt prompt displayed to the user is to be:            //
//                   Enter Exam [4] [Hit ENTER Key To Exit] : __            //
//                                                                          //
//             If the GetInt is successful, put the data in the next        //
//             available cell of the Array.                                 //
//                                                                          //
//  Written By : Thomas E. Hicks         Envir onment : Linux               //
//  Date ......: xx/xx/xxxx               Compiler ...: gcc                 //
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void AppendIntArrayGetInt (char Prompt[], int Array[], int * ActNo, int Max, 
							int Low, int High)
{
bool
	Done = false;
int
	TempActNo,	
	TempInt;
char
	TempPrompt[100];



}
 

 


Strong Suggestion


1]
I recommend that you write the functions in order.
 
2] Uncomment out just enough code in main to test the function under development.
 
3] Read on!
 
 

DisplayIntArray


1] I would include function Display.  Keep Reading!
 
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                               DisplayIntArray                            //
//                                                                          //
//  Purpose : Graphically represent the Array. Suppose the data in the      //
//            the Array is 5, 10, and 15 and the max is 6; we are going     //
//            to use Array[0]. The function call:                           //
//       ==> DispalyIntArray(Bowling, ActNoBowling, MAX_BOWLING,            //
//                           ActNoBowling, "Display Bowling Array Data"     //
//                                                                          //
//     Display Bowling Array Data                                           //
//                |--------------------|                                    //
//              3 |                 15 |                                    //
//                |--------------------|                                    //
//              2 |                 10 |                                    //
//                |--------------------|                                    //
//              1 |                  5 |                                    //
//                |--------------------|                                    //
//                 ActNo = 3   Max = 8                                      //
//                                                                          //
//       ==> DispalyIntArray(Bowling, ActNoBowling, -2,                     //
//                           MAX_BOWLING, "Display Bowling Array Container" //
//                                                                          //
//     Display Bowling Array Container                                      //
//                |--------------------|                                    //
//              6 |         -120444323 |                                    //
//                |--------------------|                                    //
//              5 |         -120444323 |                                    //
//                |--------------------|                                    //
//              4 |         -120444323 |                                    //
//                |--------------------|                                    //
//              3 |                 15 |                                    //
//                |--------------------|                                    //
//              2 |                 10 |                                    //
//                |--------------------|                                    //
//              1 |                  5 |                                    //
//                |--------------------|                                    //
//                 ActNo = 3   Max = 8                                      //
//                                                                          //
//                                                                          //
//      If we display more than ActNo, we may well have some uninitialized  //
//      garbage in our display.  If the NoToDisplay is negative display     //
//      all of the elements in the Array. If the NoToDisplay = 0 then       //
//      display only the valid data [1-ActNo].                              //
//                                                                          //
//  Written By : Thomas E. Hicks         Envir onment : Linux               //
//  Date ......: xx/xx/xxxx               Compiler ...: gcc                 //
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void DisplayIntArray (int Array[], int ActNo, int Max, int NoToDisplay, 
						  char Message[])
{

 

 
 

InitializeIntArray


1] I would write function
 
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                             InitializeIntArray                           //
//                                                                          //
//  Purpose : Completely fill the Array with 0. Set the ActNo to 0. The     //
//            function call                                                 //
//            ==> InitializeIntArray(Bowling, &ActNoBowling)                //
//                                                                          //
//     No matter what Bowling originally had, it will now contain           //
//                |--------------------|                                    //
//              8 |                  0 |                                    //
//                |--------------------|                                    //
//              7 |                  0 |                                    //
//                |--------------------|                                    //
//              6 |                  0 |                                    //
//                |--------------------|                                    //
//              5 |                  0 |                                    //
//                |--------------------|                                    //
//              4 |                  0 |                                    //
//                |--------------------|                                    //
//              3 |                  0 |                                    //
//                |--------------------|                                    //
//              2 |                  0 |                                    //
//                |--------------------|                                    //
//              1 |                  0 |                                    //
//                |--------------------|                                    //
//                 ActNo = 0   Max = 8                                      //
//                                                                          //
//  Written By : Thomas E. Hicks         Envir onment : Linux               //
//  Date ......: xx/xx/xxxx               Compiler ...: gcc                 //
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void InitializeIntArray(int Array[], int * ActNo, int Max)
{

2] And then I would uncomment just enough testing, in main,  to test it.

	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


1] I would write function
 
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                            FillIntArraySequence                          //
//                                                                          //
//  Purpose : Begin Filling Array with random numbers in the range          //
//            [Low -> High]. Do not use Array[0]. Begin with Array[1] and   //
//            then use Array[2] and then use Array[3] (etc)                 //
//   ==> FillIntArrayRandom(Bowling, &ActNoBowling, MAX_BOWLING, 0, 300, 3) //
//            will attempt to place 3 random bowling scores, in the range   //
//            [0-300], into Array. Never Overflow the Array; stop when      //
//            full. Always make sure that ActNo is accurate.                //
//                                                                          //
//     When done, the array might contain the following                      //
//                |--------------------|                                    //
//              3 |                 32 |                                    //
//                |--------------------|                                    //
//              2 |                191 |                                    //
//                |--------------------|                                    //
//              1 |                150 |                                    //
//                |--------------------|                                    //
//                 ActNo = 3   Max = 8                                      //
//                                                                          //
//  Written By : Thomas E. Hicks         Envir onment : Linux               //
//  Date ......: xx/xx/xxxx               Compiler ...: gcc                 //
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void FillIntArraySequence (int Array[], int * ActNo, int Max, int StartingNo,
                           int Multiple, int NoToFill)
{
int 

 

 

2] And then I would uncomment just enough testing, in main,  to test it.

	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


1] I would write function
 
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                             FillIntArrayRandom                           //
//                                                                          //
//  Purpose : Begin Filling Array with random numbers in the range          //
//            [Low -> High]. Do not use Array[0]. Begin with Array[1] and   //
//            then use Array[2] and then use Array[3] (etc)                 //
//   ==> FillIntArrayRandom(Bowling, &ActNoBowling, MAX_BOWLING, 0, 300, 3) //
//            will attempt to place 3 random bowling scores, in the range   //
//            [0-300], into Array. Never Overflow the Array; stop when      //
//            full. Always make sure that ActNo is accurate.                //
//                                                                          //
//     When done, the array might contain the following                      //
//                |--------------------|                                    //
//              3 |                 32 |                                    //
//                |--------------------|                                    //
//              2 |                191 |                                    //
//                |--------------------|                                    //
//              1 |                150 |                                    //
//                |--------------------|                                    //
//                 ActNo = 3   Max = 8                                      //
//                                                                          //
//  Written By : Thomas E. Hicks         Envir onment : Linux               //
//  Date ......: xx/xx/xxxx               Compiler ...: gcc                 //
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void FillIntArrayRandom (int Array[], int * ActNo, int Max, int Low, 
							 int High, int NoToFill)
{

 

 

2] And then I would uncomment just enough testing, in main,  to test it.

	FillIntArrayRandom (Exams, &ActNoExams, MAX_EXAMS, 80, 100, 5);
	DisplayIntArray (Exams, ActNoExams, MAX_EXAMS, 0, 
		                 "\nValues [80-100] <- Tried To Overflow Exams");

SumIntArray


1] I would write function
 
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                                 SumIntArray                              //
//                                                                          //
//  Purpose : Explicitly return the sum of the elements in the array. If the //
//            array is empty, return 0.                                     //
//                                                                          //
//     Suppose the Array has the following:                                 //
//                |--------------------|                                    //
//              3 |                 31 |                                    //
//                |--------------------|                                    //
//              2 |                191 |                                    //
//                |--------------------|                                    //
//              1 |                150 |                                    //
//                |--------------------|                                    //
//                 ActNo = 3   Max = 8                                      //
//                                                                          //
//  Returned Value =    372                                                 //
//                                                                          //
//  Written By : Thomas E. Hicks         Envir onment : Linux               //
//  Date ......: xx/xx/xxxx               Compiler ...: gcc                 //
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
int SumIntArray (int Array[], int ActNo)
{

 

 

2] And then I would uncomment just enough testing, in main,  to test it.

	SumExams = SumIntArray (Exams, ActNoExams);
	printf("SumExams = %d\n", SumExams);

Continue Process Until All Functions Written And Tested And Working Well

1] Write one - test one!


Copy Files

 
1] Copy file Tom-HW7.c  to /users/thicks/hw1320/hw7

1] Copy file  Utility-Tom-Hicks.h  to /users/thicks/hw1320/hw7

 


What To Turn In

1] Signed copy of page 1 of this Lab.

2] Printed copy of both files

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.