|
|
|
|
Once you enter more than one value for beginningReading, endingReading, and gallonsRequired, it only adds up the beginningrReading variable. The other two keep the original value you enter. I coded them the same way. |
|
|
|
|
|
|
OUTPUT Enter the beginning odometer reading > 10 Enter the ending odometer reading > 10 Enter the gallons required for fill-up > 10 Enter 'y' to enter more readings or 'n' to quit > y 10 10 10 Press any key to continue . . . Enter the beginning odometer reading > 10 Enter the ending odometer reading > 10 Enter the gallons required for fill-up > 10 Enter 'y' to enter more readings or 'n' to quit > y 20 10 10 Press any key to continue . . . |
|
|
I changed the beginningReading = tempBeginningReading + beginningReading; to beginningReading += tempBeginningReading and so on. |
Once you enter more than one value for beginningReading, endingReading, and gallonsRequired, it only adds up the beginningrReading variable. The other two keep the original value you enter. I coded them the same way. You did not code them the same way. beginningReading: cin >> tempBeginningReading; beginningReading = tempBeginningReading + beginningReading; endingReading: cin >> endingReading; endingReading = tempEndingReading + endingReading; gallonsRequired: cin >> gallonsRequired; gallonsRequired = tempGallonsRequired + gallonsRequired; Note that the underlining in the above code snippets is not identical. |
beginningReading: cin >> tempBeginningReading; beginningReading = tempBeginningReading + beginningReading; endingReading: cin >> endingReading; endingReading = tempEndingReading + endingReading; gallonsRequired: cin >> gallonsRequired; gallonsRequired = tempGallonsRequired + gallonsRequired; |
beginningReading: cin >> tempBeginningReading; beginningReading += tempBeginningReading; endingReading: cin >> tempEndingReading; endingReading += tempEndingReading; gallonsRequired: cin >> tempGallonsRequired; gallonsRequired += tempGallonsRequired; |
|
|
|
|
|
|