Allegheny Beverage Corp. will buy approximately 24,000 coin-operated laundry machines for $7.85 million, an acquisition that will make the firm the second-largest company in the coin-operated laundry machine business, behind Solon Automated Services of D.C.

The purchase, from United Coin Meter Co. of Southfield, Mich., also will extend by several states the area in which Allegheny distributes laundry machines and will boost the number of machines it owns to 140,000.

Company officials said yesterday that Allegheny's Macke Co. subsidiary also is negotiating with other firms to acquire additional operations in the highly profitable laundry-machine business. The company wants to become "the leading company in our type of laundry business," said Morton M. Lapides, chairman and president of Baltimore-based Allegheny.

Lapides said that the company anticipates borrowing funds needed to buy the United coin machines. Allegheny recently announced that it had signed a letter of intent with a group of thrift institutions for a $125 million term loan. Of that amount, $50 million is to be used for acquisitions. The financing is scheduled to be completed in early July, according to the company. Closing on the machine acquisition is expected to occur by July 30.

Allegheny's coin-operated laundry machines are owned by Macke and its affiliate, Macke Laundry West Inc. Macke has laundry operations in the Baltimore-Washington area, the Carolinas, Ohio, Pennsylvania, West Virginia, Indiana, Kentucky, Tennessee, Michigan, Florida and California. That includes approximately 70,000 machines acquired in four separate purchases in 1982.

With the latest acquisition, Macke also will be in Georgia, Illinois and New York.

Allegheny, which is involved in food service and vending, production and distribution of carbonated beverages and other operations, acquired Macke in 1981.