How the paint is worked out
Wall area is the room's perimeter times the wall height: 2 × (length + width) × height. A 12 × 12 foot room with 8 foot walls has 384 square feet of wall. The calculator then takes off 20 square feet for each standard door and 15 for each average window, which leaves 334 square feet. If you tick the ceiling, length × width is added. That area is multiplied by the number of coats and divided by the coverage per gallon to give gallons of paint.
Buying the right cans
The exact figure is rounded up to the nearest quart, because that is the smallest can most stores mix. Three quarts usually cost more than a gallon, so a remainder of three quarts is rounded up to another gallon. For bigger jobs, a five-gallon bucket is cheaper per gallon than five single gallons and keeps the colour consistent across walls. If you buy separate gallons of a custom colour, mix them together in a bucket before you start.
Choosing the coverage figure
The default of 350 square feet per gallon is what most interior paint labels promise on smooth, previously painted walls. Real coverage drops on rough or textured surfaces, on new drywall that soaks paint up, and when you roll on a thick coat. Use 250 to 300 for those. Primer covers about the same area as paint, so run the calculator again with one coat for a primer count.
What this does not cover
Trim, baseboards and the doors themselves take a different paint and a much smaller amount; a quart covers the trim in most rooms. Rooms that are not rectangles can be split into rectangles and added up. Ceiling paint is usually a different product from wall paint, so if you include the ceiling, buy it separately: the ceiling area times coats divided by coverage.