Calculate speed , distance and time | C # Program to calculate speed distance and time ; Function to calculate speed ; Function to calculate distance traveled ; Function to calculate time taken ; Driver code ; Calling function cal_speed ( ) ; Calling function cal_dis ( ) ; Calling function cal_time ( )
using System ; class GFG { static double cal_speed ( double dist , double time ) { Console . WriteLine ( " ▁ Distance ( km ) ▁ : ▁ " + dist ) ; Console . WriteLine ( " ▁ Time ( hr ) ▁ : ▁ " + time ) ; return dist / time ; } static double cal_dis ( double speed , double time ) { Console . WriteLine ( " ▁ Time ( hr ) ▁ : ▁ " + time ) ; Console . WriteLine ( " ▁ Speed ( km ▁ / ▁ hr ) ▁ : ▁ " + speed ) ; return speed * time ; } static double cal_time ( double dist , double speed ) { Console . WriteLine ( " ▁ Distance ( km ) ▁ : ▁ " + dist ) ; Console . WriteLine ( " ▁ Speed ( km ▁ / ▁ hr ) ▁ : ▁ " + speed ) ; return speed * dist ; } public static void Main ( ) { Console . WriteLine ( " ▁ The ▁ calculated ▁ Speed ( km ▁ / ▁ hr ) ▁ is ▁ : ▁ " + cal_speed ( 45.9 , 2.0 ) ) ; Console . WriteLine ( " ▁ The ▁ calculated ▁ Distance ( km ) ▁ : ▁ " + cal_dis ( 62.9 , 2.5 ) ) ; Console . WriteLine ( " ▁ The ▁ calculated ▁ Time ( hr ) ▁ : ▁ " + cal_time ( 48.0 , 4.5 ) ) ; } }