Question: can anyone help me fixing the code because i am getting error my code #include #include #include #include #include using namespace std; #include int main()

can anyone help me fixing the code because i am getting error

my code #include #include #include #include #include using namespace std; #include

int main() { ifstream fin("Current_Reservoir_Levels.tsv"); if (fin.fail()) {//check whether file exists or not cerr << "File cannot be opened for reading." << endl; exit(1); } //declare two vectors vector Date; vector westElVec; string header; getline(fin, header); // read one line from the file string dateArr[365], date; double eastSt, eastEl, westSt, westEl; string date1, date2; cout << "Enter starting date: "; cin >> date1; // getting starting date from user cout << "Enter ending date: "; cin >> date2; // getting ending date from user int count = 0; while (fin >> date >> eastSt >> eastEl >> westSt >> westEl) { fin.ignore(INT_MAX, ' '); //skips to the end of line, //get the record from file //check if data is between the start and end or not if (date1 <= date && date2 >= date) {//insert the data Date.push_back(date); westElVec.push_back( westEl); count++; } } //sort the data by date indecending order for (int i = 0; i < count; ++i) { for (int j = 0; j < count - i - 1; ++j) { // Comparing consecutive dates if (Date[j] < Date[j + 1]) { ////swap West basin elevation //double twestElVec = westElVec[j]; //westElVec[j] = westElVec[j + 1]; //westElVec[j + 1] = twestElVec; //swap dates string tDate = Date[j]; Date[j] = Date[j + 1]; Date[j + 1] = tDate; } } } for (int i = 0; i < count; i++) cout << Date[i] << "\t" << westElVec[i] <<"ft"<< endl; fin.close(); //system("pause"); return 0; }

Error found

On input: 01/17/2018 01/23/2018 Received output: 01/23/2018 578.55ft ft 01/22/2018 578.55ft ft 01/21/2018 578.68ft ft 01/20/2018 578.8ft ft 01/19/2018 579.59ft ft 01/18/2018 580.4ft ft 01/17/2018 581.3ft ft While expected: 01/23/2018 581.3 ft 01/22/2018 580.4 ft 01/21/2018 579.59 ft 01/20/2018 578.8 ft 01/19/2018 578.68 ft 01/18/2018 578.55 ft 01/17/2018 578.55 ft

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 Databases Questions!