diff options
| author | Joe Traver <[email protected]> | 2022-11-26 21:08:08 -0800 |
|---|---|---|
| committer | Joe Traver <[email protected]> | 2022-11-26 21:08:08 -0800 |
| commit | a456fc51e5610851be3ebb09e3d512ca260a60c3 (patch) | |
| tree | 9e0b6ffc71333e427e752b53d474f8961b4c59fb | |
| parent | Added total fare and cost per mile (diff) | |
| download | cst116-lab3-joetraver30-a456fc51e5610851be3ebb09e3d512ca260a60c3.tar.xz cst116-lab3-joetraver30-a456fc51e5610851be3ebb09e3d512ca260a60c3.zip | |
Added check for a zero distance
| -rw-r--r-- | BlankConsoleLab/BlankConsoleLab.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp index 3c0db4a..497f638 100644 --- a/BlankConsoleLab/BlankConsoleLab.cpp +++ b/BlankConsoleLab/BlankConsoleLab.cpp @@ -78,7 +78,10 @@ int ReadData(ifstream& inFile, int pick[], int drop[], int psgr[], float dist[], while (!inFile.eof()) { tfare[counter] = fare[counter] + toll[counter]; + CPM[counter] = fare[counter] / dist[counter]; + if (dist[counter] = 0) + CPM[counter] = 0; cout << fixed << setprecision(2) << setiosflags(ios::left) << setw(5) << pick[counter] << resetiosflags(ios::left) |