Please help!!!!! Where there are // is where code needs to be written please hel
ID: 3817647 • Letter: P
Question
Please help!!!!! Where there are // is where code needs to be written please help!!!!!! Don't ask for better pictures this is the best they will get just enlarge them and you should be able to read them. Thanks for any and all help!!!!
Explanation / Answer
#include <fstream>
#include <string>
using namespace std;
int main()
{
//Declare the files.
ifstream input;
ofstream output;
//Open the input file.
input.open("C:/Data/coursedata.txt", std::ios::in);
//Open the output file.
output.open("C:/Data/enrollmentdata.txt");
//Declare the variables.
int count1; //number of sections of a course.
int total; //total enrollment for a course.
string current; //current subj code and no.
string next; //next subj code and no.
string temp;
int n;
//Read data for the first section.
input>>next;
while(!(next.find("999"))){
//Continue until the end of the input file.
current = next;
count1 = 0;
total = 0;
while(next == current)
{
//Update count and total.
input>>temp;
count1 += 1;
input>>temp;
input>>n;
total += n;
//Read data for the next section.
input>>next;
}
//Write the information for the current
//course to the output file.
output<<current;
output<<count1;
output<<total;
}
//Write the information for the last course
//to the output file.
output<<next;
input>>temp;
output<<temp;
input>>temp;
input>>temp;
output<<temp;
output.close();
input.close();
return 0;
}