Total money to be paid after traveling the given number of hours | JavaScript implementation of the above approach ; calculating hours travelled
var m = 50 , n = 5 , x = 67 , h = 2927 ; var z = ( Math . ceil ( h / 60 * 1.0 ) ) ; if ( z <= n ) document . write ( z * m ) ; else document . write ( n * m + ( z - n ) * x ) ;