summaryrefslogtreecommitdiff
path: root/BlankConsoleLab/CST116-Lab3-Havaldar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'BlankConsoleLab/CST116-Lab3-Havaldar.cpp')
-rw-r--r--BlankConsoleLab/CST116-Lab3-Havaldar.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/BlankConsoleLab/CST116-Lab3-Havaldar.cpp b/BlankConsoleLab/CST116-Lab3-Havaldar.cpp
new file mode 100644
index 0000000..a10cac4
--- /dev/null
+++ b/BlankConsoleLab/CST116-Lab3-Havaldar.cpp
@@ -0,0 +1,64 @@
+// BlankConsoleLab.cpp : This file contains the 'main' function. Program execution begins and ends there.
+//
+
+#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 << "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 << 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 << left << setw(20) << "** Avg Cost Per Person: " << avg << " **" << endl;
+ cout << left << setw(20) << "** People Transported: " << totalPpl << " **" << endl;
+ cout << left << setw(20) << "** Total Cost: " << totalCost << " **" << endl;
+}
+