Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- #include <string>
- #include <fstream>
- using namespace std;
- const int timesize= 2;
- void writeoutput(ofstream&, string, int[], int[], int);
- void format(string&);
- int main()
- {
- ifstream input;
- string filename, servername;
- ofstream output;
- int hourten, hour, minten, min, secten, sec, starttotal, endtotal, sum, number, totalseconds;
- int start[timesize], end[timesize], totalsecs[50];
- cout << "What is the input file name?" << endl;
- cin >> filename;
- input.open(filename.c_str());
- output.open("baekdprog05out");
- output << " Douglas Baek Section 1010 Assignment #5" << endl << endl;
- output << left << setw(10) << "NAME" << right << setw(12) << "START TIME" << setw(12) << "END TIME" << setw(12) << "TOTAL SECS" << endl;
- input >> servername;
- while (input)
- {
- int n = 0;
- for (int i = 0; i < 6; i++)
- input >> start[i];
- for (int i = 0; i < 6; i++)
- input >> end[i];
- starttotal = ((start[0] * 60) * 60) + (start[1] * 60) + start[2];
- endtotal = ((end[0] * 60) * 60) + (end[1] * 60) + end[2];
- totalseconds = endtotal - starttotal;
- totalsecs[n] = totalseconds;
- writeoutput(output, servername, start, end, totalseconds);
- //n++;
- input >> servername;
- }
- input.close();
- output.close();
- return 0;
- }
- void writeoutput(ofstream& out, string name, int start[], int end[], int total)
- {
- format(name);
- out << left << setw(10) << name << right << setw(6) << start[0] << ':' << start[1] << ':' << start[2] << setw(6)
- << end[0] << ':' << end[1] << ':' << end[2]<< setw(6) << total << endl;
- }
- void format(string& word)
- {
- word[0] = toupper(word[0]);
- for (int i = 1; i<word.length(); i++)
- word[i] = tolower(word[i]);
- }
- void average()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement