You Don't Know How To Maintain Speed

To get to town, we that live on the mountain have to drive downhill, uphill, and then a steep downhill.
The speed limit on this road is 40 mph, so what did the car in front of me do today? Uphill 35 mph and downhill, well, halfway down, it took him that long to coast to 45 mph. Highways are not rollercoasters. Now, what should one do in a 40 mph zone? Straightaway, 40 mph; uphill, 40 mph; downhill, 40 mph, so how do I accomplish this?
Uphill, press down on the gas pedal; downhill, press down on the brake pedal.  On the straightaway, look at the speedometer once in a while.  I hope that this is not too complicated.