Calculate speed , distance and time | Function to calculate speed ; Function to calculate distance traveled ; Function to calculate time taken ; Calling function cal_speed ( ) ; Calling function cal_dis ( ) ; Calling function cal_time ( )
function cal_speed ( dist , time ) { document . write ( " " + dist + " " ) ; document . write ( " " + time + " " ) ; return dist / time ; } function cal_dis ( speed , time ) { document . write ( " " + time + " " ) ; document . write ( " " + speed + " " ) ; return speed * time ; } function cal_time ( dist , speed ) { document . write ( " " + dist + " " ) ; document . write ( " " + speed + " " ) ; return speed * dist ; } document . write ( " " + cal_speed ( 45.9 , 2.0 ) + " " ) ; document . write ( " " ) ; document . write ( " " + cal_dis ( 62.9 , 2.5 ) + " " ) ; document . write ( " " ) ; document . write ( " " + cal_time ( 48.0 , 4.5 ) + " " ) ;