Find the number of spectators standing in the stadium at time t | Java program to find number of spectators standing at a time ; If the time is less than k then we can print directly t time . ; If the time is n then k spectators are standing . ; Otherwise we calculate the spectators standing . ; Driver code ; Stores the value of n , k and t t is time n & k is the number of specators
class GFG { static void result ( long n , long k , long t ) { if ( t <= k ) System . out . println ( t ) ; else if ( t <= n ) System . out . println ( k ) ; else { long temp = t - n ; temp = k - temp ; System . out . println ( temp ) ; } } public static void main ( String args [ ] ) { long n , k , t ; n = 10 ; k = 5 ; t = 12 ; result ( n , k , t ) ; } }