Question: 2 2 . 3 Filtering data Write a C + + program to 1 ) read the real - valued data from the input text

22.3 Filtering data
Write a C++ program to
1) read the real-valued data from the input text file called filexx (where xx is a number).
2) apply the following filter to the data
filtered_output(0)= unfiltered_input(0)
filtered_output(n)=0.9375* filtered_output(n-1)+0.0625* unfiltered_input(n)
3) print the original data and the filtered data into the output file called outputfilexx (where xx is a number). The following format should be used
HH.H TT.TTTTTT
where
HH.H represents original data
TT.TTTTTT represents the filtered data with 6 decimal digits of precision.
Each entry should be separate by a single tab character (\t).
For example, if the original data is
67.7
67.6
67.7
67.6
67.6
67.3
67.4
the output is
67.767.700000
67.667.693750
67.767.694141
67.667.688257
67.667.682741
67.367.658819
67.467.642643
Observations:
1) the first data (at index 0) has no filter
2) the second data on the second column 67.693750 is from
0.9375* filtered_output(n-1)+0.0625* unfiltered_input(n)=0.9375*67.7+0.0625*67.6
3) the third data on the second column 67.694141 is from
0.9375* filtered_output(n-1)+0.0625* unfiltered_input(n)=0.9375*67.693750+0.0625*67.7
this is what i have
#include
using namespace std;
// Before submitting your code, do step 1) and 2) below
//1) uncomment this part since zyBooks use it.
/*int main(int argc, const char* argv[]){
if (argc !=3)
{
std::cout <<"./hw3 inputFile outputFile" << std::endl;
return EXIT_FAILURE;
}
string inputFileName = argv[1];
string outputFileName = argv[2];*/
///////////////////// uncomment above befofre submitting on zyBooks /////////////////
//2) Comment the next 3 lines below
int main(void){
string inputFileName = "file1"; //Do NOT change the name "inputFileName" since used above
string outputFileName = "outputfile1"; //Do NOT change the name "outputFileName" since used above
return 0;
}
this is whats in chegs solutions, it won't open files
Could not find file: outputfile1
Error opening file(s).
Run command
./a.out file1 outputfile1
Input
file1 outputfile1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!