Question
Goals: Developing problem-solving skills, using functions and arrays Problem: You have been asked to use your programming skills to help analyze data from a company
Goals: Developing problem-solving skills, using functions and arrays Problem: You have been asked to use your programming skills to help analyze data from a company name Resistors-R-Us. This company has different locations producing resistors with different formulas. They have automated the data collection so that the resistances are stored in a file containing a table (2-D array). Each row of the table represents a specific formulation and each column represents a specific company location. Your program should have a main function and 4 other functions as described below. The company has stated that there will not be more than 80 formulations and not more than 10 locations using the same formulations. One function should open the file Resistors-R-Us.dat and read the first line that contains the number of formulations (the first value) and number of locations (the second value) using those formulations. Using these two values, your function should then read the rest of the data and store the values in a 2-dimensional array with formulations in rows and the locations in columns. As the resistances are being stored, a message should be output if any resistance is not in the range of 3 to 3.5 inclusive and the number of resistances not in the range should be counted. The message should output the resistance, the location and the formulation as the example below. The value of 2.9427 ohms from location 1 for formulation 6 is suspect. The resistance should still be stored in the array. The 2-dimensional array, the number of formulations and the number locations should be sent back to the function call. The number of resistances not in the range of 3 ohms to 3.5 ohms inclusive should be returned to the function call. One function should accept the 2-dimensional array, the number of formulations and number of locations then create a 1-dimensional array containing the minimum resistances for each formulation and create a 1-dimensional array containing the maximum resistances for each formulation. This function should call the function to output a 1-dimensional array once for the minimum and once for the maximum values before sending these arrays back to the function call. One function should accept the 2-dimensional array and determine the average resistance for each formulation. The average resistance for each formulation should be calculated without including the maximum and minimum resistance for that formulation, therefore this function will need to call the function that calculates the minimum and maximum resistances for each formulation. The average resistances for the formulations should be stored in another 1- dimensional array which is sent back to the function call. One function that will accept a 1-dimensional array, the number of values stored in the array and a description of what is stored in the array, e.g minimum resistance for each formulation, average resistance for each formulation, etc. The function will then output the description and the values. The values should be output to 4 significant digits; The main function should prompt the user to enter the filename for the data file and call the function to import the data from the file into a 2-dimensional file. The main function should output the number of formulations (rows), the number of locations (columns), and the number of resistances that were not in the correct range. Next the main function should call the function to calculate the averages of the formulations. The main function should then call the function to output a 1-dimensional array sending the array of averages to the function to calculate the 1- dimensional array. A data file, Resistors-R-Us.dat has been posted on CANVAS. However, you should create your own file with fewer formulations and locations to test your code. Do not use pointers, dynamic arrays and/or vectors to complete this project.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started