any idea why the while loop exits the program rather then continue on to the coomand after it is finished ? |
Are you sure the console window is not simply closing after executing your summary?
http://www.cplusplus.com/forum/beginner/1988/
You have some logic errors:
Line 48: What is the point of incrementing numberTrips here, when you overlay it at line 51.
Line 59: numberTrips will never be anything other than 0. That's how you broke out of your loop at line 54.
Line 57: ppg is uninitialized.
Line 61-62: You will never prompt for ppg because your for loop never executes.
Line 74-75: Your calculation of averagePpg and mpd is invalid because ppg was never initialized.
Lines 73-74: Your calculations will only use the last values of endRead, beginningRead and gallonsRequired. You want to calculate the total miles traveled and total gallons inside your while loop, then use those totals to calculate averageMpg and averagePpg.
Line 73: Your calculation of averageMpg is incorrect. You want to DIVIDE totalMiles by totalGallons.
PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.