ok what im trying to do is....write a program that will calculate the frequency distribution using an interval of 10 million gallons per day. the input specification is to use the array sewage_amt [100] to read the number of millions of gallons from file EX6_1.DAT. the output specification is to display the following...
Day No. Millions of gallons
1 123
2 134
3 122
...
Sewage per day Freq of occurance
81-90 3
91-100 3
101-111 0
... ...
but i have to change it so that the input is read by calling a function
read_data ().....
ok i got confused when i tried to write the program and then trying to convert it....heres the code
# include <iostream>
# include <cmath>
# include <iomanip>
# include <fstream>
using namespace std;
//function dec
int read_data ();
int main()
{
int i;
// printing to the screen the table
cout <<"Day No. Millions of gallons."<<endl;
cout << i+1<<setw(10)<<sewage_amt[i]<<endl<<endl<<endl;
system("pause");
return 0;
}
int read_data ()
{
// declaring the array and counters for loops and counters
int size = 0;
int sewage_amt[100];
int i,j,k;
int begin = 81,end = 90;
ifstream infile ("C:\\EX6_1.DAT");
// for loop for the output of file
for (i=0;!infile.eof();i++)
{
infile >> sewage_amt[i];
size++;
}
// for loop for the freq table
for(j=0;j<7;j++)
{
for (k=0; k < size;k++)
{
// if statement for the increment of each occurance
if (sewage_amt[i] > begin && sewage_amt[i]< end)
{
count++;
}
cout << "begin end"<<count<<endl;
count = 0; begin +=10; end +=10;
}
}
return sewage_amt[i];
}
heres the file EX6_1.DAT
123,134,122,128,116,96,83,144,143,156,128,138,
121,129,117,96,87,148,149,151,129,138,127,
126,115,94,83,142