Write a program that: (a) calls function called cleandata that reads each value
ID: 3821179 • Letter: W
Question
Write a program that:
(a) calls function called cleandata that reads each value into a one-dimensional array called NELM and writes it to a new file if it is not a -9999 value. This function should also count the number of bad values removed and the number of valid data points transcribed to the new file, and prints these counts points to the screen.
(b) calls function named frequency that determines the average and counts the number of occurrences of the values 1, 2, 3, 4, 5, 6, 7 and returns to another data file both the average and the relative frequency of occurrence of each numerical value. (Hint: Relative frequency is just the percent of times a value occurs compared to the total number of data points collected.)
Please use this data file:
4
5
5
3
4
4
3
-9999
3
5
2
4
3
6
5
3
4
3
7
5
3
4
5
4
3
4
-9999
-9999
6
3
1
5
4
3
1
3
5
4
4
4
4
4
4
4
4
4
4
5
4
3
5
6
3
Explanation / Answer
#include <iostream>
#include <fstream>
using namespace std;
const int MAX = 1000;
typedef char File_array[MAX];
int main()
{
char character;
File_array file;
int count;
ifstream in_stream;
in_stream.open("6-1-2.cpp");
in_stream.get(character);
for (count = 0 ; ! in_stream.eof() && count < MAX ; count++)
{
file[count] = character;
in_stream.get(character);
}
in_stream.close();
while (count > 0)
cout << file[--count];
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.