Total money to be paid after traveling the given number of hours | Java implementation of the above approach ; calculating hours travelled
import java . io . * ; class GFG { public static void main ( String [ ] args ) { float m = 50 , n = 5 , x = 67 , h = 2927 ; int z = ( int ) ( Math . ceil ( h / 60 * 1.0 ) ) ; if ( z <= n ) System . out . println ( z * m ) ; else System . out . println ( n * m + ( z - n ) * x ) ; } }