Guest User

Untitled

a guest
Feb 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.60 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <iomanip>
  4. using namespace std;
  5. int main()
  6. {
  7.     int event, lastevent(1), task, tasksum(0), days, daysmax(0), total(0);
  8.    
  9.     string inputproj4, outputproj4a, outputproj4b;
  10.    
  11.     cout<<"Please enter the name of the input file. ";
  12.     cin>>inputproj4;
  13.    
  14.     cout<<"Please enter the name of the first output file. ";
  15.     cin>>outputproj4a;
  16.    
  17.     cout<<"Please enter the name of the second output file. ";
  18.     cin>>outputproj4b;
  19.    
  20.     ifstream infile;
  21.     infile.open(inputproj4.c_str());
  22.     ofstream outfilea;
  23.     outfilea.open(outputproj4a.c_str());
  24.     ofstream outfileb;
  25.     outfileb.open(outputproj4b.c_str());
  26.    
  27.     if (infile.fail())
  28.     {
  29.         cerr<<"There is no such input file!\n";
  30.         exit(1);
  31.     }
  32.    
  33.     while (!infile.eof())
  34.     {
  35.         infile>>event>>task>>days;
  36.        
  37.         if (event != lastevent)
  38.         {
  39.             total += daysmax;
  40.    
  41.             outfilea<<"Event #"<<lastevent<<" will take a maximum of "<<daysmax<<" days."<<endl;
  42.    
  43.             outfileb<<"Event #"<<lastevent<<" has "<<tasksum<<" tasks."<<endl;
  44.            
  45.             daysmax = 0;
  46.            
  47.             tasksum = 0;
  48.            
  49.             lastevent=event;
  50.         }
  51.    
  52.         tasksum += 1;
  53.    
  54.         if (days > daysmax)
  55.                 {
  56.                 daysmax = days;
  57.                 }
  58.        
  59.         if (days > 5)
  60.             cout<<"Task #"<<task<<" of event #"<<event<<" will take more than five days. "<<endl;
  61.     }
  62.  
  63.     total += daysmax;
  64.    
  65.     outfilea<<"Event #"<<lastevent<<" will take a maximum of "<<daysmax<<" days."<<endl;
  66.    
  67.     outfileb<<"Event #"<<lastevent<<" has "<<tasksum<<" tasks."<<endl;
  68.    
  69.     outfilea<<"The project will take a total of "<<total<<" days to complete."<<endl;
  70.    
  71.     infile.close();
  72.     outfilea.close();
  73.     outfileb.close();
  74.    
  75.     return(0);
  76. }
Add Comment
Please, Sign In to add comment