Question: In this assignment, you will master the usage of functions ( void and value returning ) , calling functions, using return values from functions, actual
In this assignment, you will master the usage of functions void and value returning calling functions, using return values from functions, actual and formal parameters, value and reference parameters, and passing arrays as parameters.
A sign company needs you to help them calculate the areas of some of their signs, and then find some statistics on the areas you find. Write a program that:
Opens an input file using a user defined function written by you called void openFile which is described on the following pages.
Reads all the values from the input file into parallel arrays keeping track of the size of inputs from the file using a user defined function written by you callod void neadFile thich is described on the following pages.
Calculates the area of either the hexagon, octagon, or decagon, stored in the parallel arrays and stores the area into a rd parallel array using a user defined function written by you called void calculateAreas which is described on the following pages.
Finds the index of the minimum area calculated using a user defined function written by you called int minInder which is described on the following pages.
Finds the index of the maximum arca caleulated using a user defined function written by you called int maxIndex which is described on the following pages.
Writes all types, side lengths, and areas calculated to a file using a user defined function written by you called int writeAreas ToFile which is deseribed on the following pages.
Writes the minimum and maximum index, type, side length, and area to a file using a user defined function written by you called int uriteStatsToFile which is described on the following pages.
Descriptions for the required functions to be written can be found on the following pages. The functions must be written and used or your grade will be reduced up to
For additional assistance sce the following:
Required Function Descriptions
void openFileifstream &iFile
iFile Input file object to open input file into passed by reference
This function should:
Prompt the user for an input file name and read in the input file name as a string.
Attempt to open the file name from step into File.
Validate the file was able to be opened in the previous step. If the file did not open output an error "Error: Invalid Filename" and start over from step otherwise the function should terminate.
void readFileifstream iFile, string types
double sideLengths int readCount, const int MAXSIZE
iFile Input tile object to reud input from passed by referenco
types Array to place diti from the fint column of iFile into.
sideLengtha Arriy to place datin from the second column of iFile lato.
read Count Variable to keep trick of size of items in the arrays passed by refenenco
MAXSIZE Maximum amount of itemi the arriya con hold.
This function should rend through iFile extracting pain of data using the stream extraction operator owen for the strings aisce there is no spacing in the stringe whd store the rend in typo and wide length from onch after each pair of data is rend inatored If there is too many pleces of data in the file MAXSIZE pairs of data aro read in the crror "Error. Max input size rend in shoukd be output one time and the function should terminate returning MAXSIZE pairn of dats in the parameter arrays Outside of the too many lems in the flle error, you cen issume the input the will have no erroni in it all typos and slde lengths will be valld
void calculateAreas string types double sideLengths double areas const int SIZE
types: Array of types of shapes.
sideLengths Array of side lengthe of shapes.
areas Array to ntore area calculations in
SIZE Size of items in types and sideLengths
This function should iterate each of the shapes in the parallel arrays and caleulate the proper arca for each shape bused on the type of the shape. The calculated areashould then be stored into the proper index in the areas array so the areas array is also parallel with the types and sideLengths arrays.
The equation for area of a hexagon is:
The equation for area of a octagon is:
The equation for area of a decagon is:
side Lengthi
int minIndexdouble areas const int SIZE
areas Array of values to find the minimum of
SIZE Size of items in areas
This function should linearly search through areas to find the index of the minimum value in the array. Once every item has been iterated over and subsequently the index of the minimum value in the array found the index of the minimum value should be returned.
int maxIndexdouble areas const int SIZE
area
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
