U=w2*c.
3*w + 2*c = 100.
c=(100-3w)/2.
U=w2*(100-3w)/2.
dU/dw=2w*(100-3w)/2 + w2*-3/2=0.
Solving for w yields w=200/9.
With wine costing $3 a glass this will cost 3*200/9=$66.67, leaving $33.33 for cigars, for which he can buy 16.67.
Michael Shackleford, A.S.A.