Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- using namespace std;
- int main()
- {
- int event, lastevent(1), task, tasksum(0), days, daysmax(0), total(0);
- string inputproj4, outputproj4a, outputproj4b;
- cout<<"Please enter the name of the input file. ";
- cin>>inputproj4;
- cout<<"Please enter the name of the first output file. ";
- cin>>outputproj4a;
- cout<<"Please enter the name of the second output file. ";
- cin>>outputproj4b;
- ifstream infile;
- infile.open(inputproj4.c_str());
- ofstream outfilea;
- outfilea.open(outputproj4a.c_str());
- ofstream outfileb;
- outfileb.open(outputproj4b.c_str());
- if (infile.fail())
- {
- cerr<<"There is no such input file!\n";
- exit(1);
- }
- while (!infile.eof())
- {
- infile>>event>>task>>days;
- if (event != lastevent)
- {
- total += daysmax;
- outfilea<<"Event #"<<lastevent<<" will take a maximum of "<<daysmax<<" days."<<endl;
- outfileb<<"Event #"<<lastevent<<" has "<<tasksum<<" tasks."<<endl;
- daysmax = 0;
- tasksum = 0;
- lastevent=event;
- }
- tasksum += 1;
- if (days > daysmax)
- {
- daysmax = days;
- }
- if (days > 5)
- cout<<"Task #"<<task<<" of event #"<<event<<" will take more than five days. "<<endl;
- }
- total += daysmax;
- outfilea<<"Event #"<<lastevent<<" will take a maximum of "<<daysmax<<" days."<<endl;
- outfileb<<"Event #"<<lastevent<<" has "<<tasksum<<" tasks."<<endl;
- outfilea<<"The project will take a total of "<<total<<" days to complete."<<endl;
- infile.close();
- outfilea.close();
- outfileb.close();
- return(0);
- }
Add Comment
Please, Sign In to add comment