Advertisement
Guest User

Untitled

a guest
May 1st, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <iomanip>
  4. #include <string>
  5. #include <fstream>
  6.  
  7. using namespace std;
  8. const int timesize= 2;
  9.  
  10. void writeoutput(ofstream&, string, int[], int[], int);
  11. void format(string&);
  12.  
  13.  
  14.  
  15. int main()
  16. {
  17. ifstream input;
  18. string filename, servername;
  19. ofstream output;
  20. int hourten, hour, minten, min, secten, sec, starttotal, endtotal, sum, number, totalseconds;
  21. int start[timesize], end[timesize], totalsecs[50];
  22.  
  23.  
  24. cout << "What is the input file name?" << endl;
  25. cin >> filename;
  26. input.open(filename.c_str());
  27. output.open("baekdprog05out");
  28. output << " Douglas Baek Section 1010 Assignment #5" << endl << endl;
  29. output << left << setw(10) << "NAME" << right << setw(12) << "START TIME" << setw(12) << "END TIME" << setw(12) << "TOTAL SECS" << endl;
  30.  
  31.  
  32. input >> servername;
  33. while (input)
  34. {
  35. int n = 0;
  36. for (int i = 0; i < 6; i++)
  37. input >> start[i];
  38. for (int i = 0; i < 6; i++)
  39. input >> end[i];
  40. starttotal = ((start[0] * 60) * 60) + (start[1] * 60) + start[2];
  41. endtotal = ((end[0] * 60) * 60) + (end[1] * 60) + end[2];
  42. totalseconds = endtotal - starttotal;
  43. totalsecs[n] = totalseconds;
  44.  
  45. writeoutput(output, servername, start, end, totalseconds);
  46.  
  47. //n++;
  48.  
  49.  
  50. input >> servername;
  51. }
  52. input.close();
  53.  
  54.  
  55. output.close();
  56.  
  57.  
  58. return 0;
  59. }
  60.  
  61.  
  62. void writeoutput(ofstream& out, string name, int start[], int end[], int total)
  63. {
  64. format(name);
  65. out << left << setw(10) << name << right << setw(6) << start[0] << ':' << start[1] << ':' << start[2] << setw(6)
  66. << end[0] << ':' << end[1] << ':' << end[2]<< setw(6) << total << endl;
  67.  
  68. }
  69.  
  70. void format(string& word)
  71. {
  72. word[0] = toupper(word[0]);
  73. for (int i = 1; i<word.length(); i++)
  74. word[i] = tolower(word[i]);
  75. }
  76.  
  77. void average()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement