/* Abdullah Havaldar */ //precompiler directives #include #include #include 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; }