Calculate money placed in boxes after N days based on given conditions | Java program for above approach ; Function to find total money placed in the box ; Number of complete weeks ; Remaining days in the last week ; Driver Code ; Input ; Function call to find the total money placed
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static void totalMoney ( int N ) { int CompWeeks = N / 7 ; int RemDays = N % 7 ; int X = 28 * CompWeeks + 7 * ( CompWeeks * ( CompWeeks - 1 ) / 2 ) ; int Y = RemDays * ( RemDays + 1 ) / 2 + CompWeeks * RemDays ; int cost = X + Y ; System . out . print ( cost ) ; } public static void main ( String [ ] args ) { int N = 15 ; totalMoney ( N ) ; } }