Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Arifur Rahman
- CS 136
- MELISSA LYNCH
- LAB 3A
- */
- #include <iostream>
- #include <fstream>
- #include <cstdlib>
- #include <climits>
- #include <string>
- using namespace std;
- int main(){
- string date;
- double min = 10000;
- double max = 0;
- double eastSt,eastEl,westSt,westEl;
- ifstream fin("Current_Reservoir_Levels.tsv");
- if (fin.fail()) {
- cerr << "File cannot be opened for reading." << endl;
- exit(1); // exit if failed to open the file
- }
- string junk; // new string variable
- getline(fin, junk); // read one line from the file
- while(fin >> date >> eastSt >> eastEl >> westSt >> westEl) {
- // this loop reads the file line-by-line
- // extracting 5 values on each iteration
- fin.ignore(INT_MAX, '\n'); //skips to the end of line,
- //ignoring the remaining columns
- // for example, to print the date and East basin storage:
- if (max < eastSt)
- {
- max = eastSt;
- }
- else if (min > eastSt)
- {
- min = eastSt;
- }
- }
- cout << "minimun storage in East basin: " << min << "billion gallons" << endl;
- cout << "Maximum storage in East basin: " << max << "billion gallons" << endl;
- fin.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement