blob: a95f7ffc994c964e848e2b7e405a03775c086392 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/*
Abdullah Havaldar
*/
//precompiler directives
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
using std::cout;
using std::cin;
using std::endl;
int main()
{
string fileName;
int numLines = 0;
cout << "Please enter the input file name including extension: ";
cin >> fileName;
ifstream theFile(fileName);
int count = 1;
int pick;
int drop;
int ppl;
double dis;
double fare;
double toll;
double avg = 0;
int totalPpl = 0;
double totalCost = 0;
cout << left;
cout << setw(20) << "Trip"
<< setw(20) << "Pickup"
<< setw(20) << "Dropoff"
<< setw(20) << "#ppl"
<< setw(20) << "Distance"
<< setw(20) << "Fare"
<< setw(20) << "Toll"
<< setw(20) << "Total"
<< setw(20) << "Cost/Mi"
<< endl;
while (theFile >> pick >> drop >> ppl >> dis >> fare >> toll) {
double total = fare + toll;
double cpm = total / dis;
cout << setw(20) << count
<< setw(20) << pick
<< setw(20) << drop
<< setw(20) << ppl
<< setw(20) << dis
<< setw(20) << fare
<< setw(20) << toll
<< setw(20) << total
<< setw(20) << setprecision(3) << cpm << endl;
count++;
totalPpl += ppl;
totalCost += total;
}
avg = totalCost / totalPpl;
cout << " " << endl;
cout << " " << endl;
cout << " " << endl;
cout << setw(20) << "** Avg Cost Per Person: " << avg << " **" << endl;
cout << setw(20) << "** People Transported: " << totalPpl << " **" << endl;
cout << setw(20) << "** Total Cost: " << setprecision(7) << totalCost << " **" << endl;
}
|