Calculate money placed in boxes after N days based on given conditions | Java program for the above approach ; Function to find the total money placed in boxes after N days ; Stores the total money ; Iterate for N days ; Adding the Week number ; Adding previous amount + 1 ; Return the total amount ; Driver Code ; Input ; Function call to find total money placed
import java . io . * ; class GFG { public static int totalMoney ( int N ) { int ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { ans += i / 7 ; ans += ( i % 7 + 1 ) ; } return ans ; } public static void main ( String [ ] args ) { int N = 15 ; System . out . println ( totalMoney ( N ) ) ; } }