I need help I have tried three times to make this program work and every-time I get more and more confused.

Write a program that performs a threshold filter on a sequence of one-dimensional data.
A threshold filter replaces values in an array with preset constants based on whether the values are in the "upper", "middle", or "lower" range of the data. We will use these constants for this particular Program

Range/Replacement

a>90%/a=2;

10%<=a<=90%/a=1;

a<10%/a=0;

Requirements

You must use a one-dimensional integer array to hold the data, it should hold up to 64 data points.Always open a file named "DATA". The format of the file is stated below. Read the size of the sequence, checking for an input error with something like if( !(inf >> size) ), which would signify a bad data file. Read size data values into your one-dimensional integer array, if there is an input error, print an error message and exit(1) the program. You may check that each array element is read from the input file successfully, or After the data elements have been read, you may use if( !infile ) to detect an input error. Scan through the array to find the maximum value in the array (only scan through size elements!). Calculate two double thresholds at 10% and 90% of the maximum value. Iterate through the array, replacing each element value with either a 0, 1, or 2 depending on the replacement table above. Finally, print the elements of the new array to the console window. Print them all on one line, without intervening whitespace.

Recommended Answers

All 2 Replies

My psychic powers aren't working. I have no idea what you tried any of the three times so have no suggestions other than think through the problem on paper and don't try to code anything until you understand the problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.