The average national price of a gallon of gas has passed the $4 mark for the first time in more than three years.