Find if the glass will be empty or not when the rate of drinking is given | JavaScript implementation of the approach ; Function to return the time when the glass will be empty ; Check the condition when the glass will never be empty ; Find the time ; Driver code
const pie = 3.1415926535897 ; function findsolution ( d , h , m , n ) { var k = ( 4 * m ) / ( pie * d * d ) ; if ( n > k ) return - 1 ; var ans = ( h / ( k - n ) ) ; return ans ; } var d = 1 , h = 1 , m = 1 , n = 1 ; document . write ( findsolution ( d , h , m , n ) . toFixed ( 5 ) ) ;