Why is the capacitor voltage Vin*D?
The voltage will ideally approach the average input voltage. If the input waveform is a square wave with duty cycle D such that D = ton/(ton + toff) and the voltage is 0V for toff and Vin for ton, then the average is Vin*D.