Calculate sum of scores after N days based on given conditions | Java program for the above approach ; Function to calculate sum of scores after n days ; Store the number of full weeks ; Stores the remaining days in the last week ; Store the sum of scores in the first F full weeks ; Store the sum of scores in the last week ; Print the result ; Driver Code
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static void findScoreSum ( int n ) { int F = n / 7 ; int D = n % 7 ; int fullWeekScore = ( 49 + 7 * F ) * F / 2 ; int lastNonFullWeekScore = ( 2 * F + D + 1 ) * D / 2 ; System . out . println ( fullWeekScore + lastNonFullWeekScore ) ; } public static void main ( String [ ] args ) { int N = 8 ; findScoreSum ( N ) ; } }