Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // basic file operations
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main () {
- ifstream infile;
- string line;
- line = "";
- string name;
- name = "";
- double rate;
- rate = 0.0;
- double monday;
- monday = 0.0;
- double tuesday;
- tuesday = 0.0;
- double wed;
- wed = 0.0;
- double thursday;
- thursday = 0.0;
- double friday;
- friday = 0.0;
- double total;
- total = 0.0;
- while (true)
- {
- string infilename;
- cout << "Please Enter the name of the file to be opened: ";
- getline( cin, infilename);
- infile.open( infilename.c_str() );
- if(infile)break;
- cout << "Invalid File. Please, try again."<< flush;
- }
- //while (!infile.eof() )
- {
- int i;
- for(i = 0; i < 1; i++)
- {
- getline (infile, line);
- name = line;
- cout << "name: " << name << endl;
- infile >> rate;
- cout <<"rate: " << rate << endl;
- infile >> monday;
- cout << "M: " << monday << endl;
- infile >> tuesday;
- cout << "T: " << tuesday << endl;
- infile >> wed;
- cout << "W: " << wed << endl;
- infile >> thursday;
- cout << "R: " << thursday << endl;
- infile >> friday;
- cout << "F: " << friday << endl;
- total = monday+tuesday+wed+thursday+friday;
- cout << "Total: " << total << endl;
- }
- //}
- infile.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement