How much paint a room needs
The math behind every paint estimate is the same: find the square footage to be painted, divide by the coverage of one gallon, and multiply by the number of coats. Wall area is the room's perimeter times the ceiling height, so a 12 x 12 room with 8-foot ceilings has 2 x (12 + 12) x 8 = 384 sq ft of wall. You do not paint doors and windows with the wall color, so subtract them: a standard interior door is about 20 sq ft and an average window about 15 sq ft. One door and two windows remove 50 sq ft, leaving 334 sq ft.
Most interior latex paints cover 350-400 sq ft per gallon on a smooth, previously painted surface, and the calculator defaults to 375. At that rate the example room needs 334 / 375 = 0.89 gallons per coat, or 1.78 gallons for two coats. Paint is sold in gallons and quarts, and three quarts cost about as much as a full gallon, so the tool rounds up to whole quarts and then to whole gallons whenever the remainder is three quarts: you would buy 2 gallons. Checking the ceiling box adds 12 x 12 = 144 sq ft at the same coat count, which is 0.77 gallons, so one more gallon of flat ceiling white. A single primer coat on 334 sq ft is another 0.89 gallons, again one gallon.
When you need two coats, and when you need primer
Two coats are the norm for a uniform finish, and they are essential when changing color, going from a dark shade to a light one, or covering a repaired wall. One coat of a premium paint-and-primer product can be enough when repainting the same color in the same sheen. Bare drywall, patched areas, glossy surfaces, stains and dramatic color changes call for a separate primer coat; tinted primer makes a big difference under deep reds and blues.
Coverage drops on rough or porous surfaces. Fresh drywall and heavy texture can soak up paint at 250-300 sq ft per gallon on the first coat, and the same is true of rough stucco or masonry. Enter a lower coverage figure in those cases. Trim, baseboards and doors are usually painted in a semi-gloss and are not included here; a quart covers roughly 90-100 sq ft, which handles the trim in one average bedroom.
Buying and leftovers
Buy all the paint for a color at once and have the store box (intermix) the cans, so a slight tint difference between gallons does not show up as a line in the middle of a wall. Keep a labeled quart for touch-ups; most people never regret the extra can but do regret running out with one wall left. Five-gallon buckets are cheaper per gallon when you are painting a whole floor of a house in one color. Finally, measure with a tape rather than guessing: a room that is actually 13 x 14 with 9-foot ceilings has 486 sq ft of wall, a full 25% more than the 12 x 12 x 8 estimate.