87 122
Assignments Done
98.6%
Successfully Done
In May 2020

# Answer to Question #12161 in C++ for Jillian King

Question #12161
Using arrays in C++: The number of millions of gallons of sewage that are disposed of each day for a major city is measured continuously for about one month. The records, saved in a file, EX6_1.DAT, follow: 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 Write a program to calculate the frequency distribution using an interval of 10 million gallons per day. But modify the program so that the input is read by calling a function named read_data (). The input specs is to use the array sewage_amt[100] to read the number of millions of gallons from file EX6_1.DAT. The output spec is to display the following data on screen: Day no. Millions of gallons 1 123 2 134 3 122 ... Sewage per day frequency of occurrence 81-90 3 91-100 3 101-111 0 ...
1
2012-07-24T10:34:42-0400
#include <iostream>
#include <fstream>
using namespace std;
#include <string>
void process_and_out(int *, int);
int main () {
int sewage_amt[100];
int lenght;
process_and_out(sewage_amt,lenght);

system ("pause");
return 0;
}

ifstream fi;
fi.open("EX6_1.DAT");
if (!fi) {
}
string a;
string num;
fi>>a;
lenght = 0;
for (int i = 0 ; i < a.size() ; i++, lenght++){
& while ( i < a.size() && a[i] != ',' )
& {
& num += a[i];
& i++;
& }
& array[lenght] = atoi(num.c_str());
& num.clear();
&
}
}
void process_and_out(int array[100], int lenght){
int frequency[20] = {};
int min, max;
min = max = array[0];
for (int i = 0 ; i < lenght ; i++){
& if (array[i] > max ) max = array[i];
& if (array[i] < min ) min = array[i];
}
max /= 10 ;
max = max * 10 + 10;
min /= 10;
min *= 10;
int minSave = min;

for (int i = 0 ; i < lenght ; i++){
& int index = array[i]/10 - min / 10;
& frequency[index]++;
}

for (int i = 0 ; i < lenght ; i++){
& cout << i+1 << ' '<< array[i]<<endl;
}
cout<<"Sewage per day frequency of occurrence:\n";
for (int i = 0 ; i < (max-minSave) / 10 ; i++){
& cout << min+1 << '-';
& min += 10;
& cout<<min << ' ' <<frequency[i]<< endl;

}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Assignment Expert
15.07.14, 18:15

Dear Carrie,

Carrie
11.07.14, 17:21

I keep getting this error message. Can you plz help me?
1>------ Build started: Project: Sewage, Configuration: Debug Win32 ------
1> Sewage.cpp
1>c:\users\carrie\documents\visual studio 2010\projects\sewage\sewage\sewage.cpp(72): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========