Find temperature of missing days using given sum and average | Java program for the above approach ; Function for finding the temperature ; Store Day1 - Day2 in diff ; Remaining from s will be Day1 ; Print Day1 and Day2 ; Driver Code ; Functions
class GFG { static void findTemperature ( int x , int y , int s ) { double Day1 , Day2 ; double diff = ( x - y ) * 6 ; Day2 = ( diff + s ) / 2 ; Day1 = s - Day2 ; System . out . println ( " Day1 ▁ : ▁ " + Day1 ) ; System . out . println ( " Day2 ▁ : ▁ " + Day2 ) ; } public static void main ( String [ ] args ) { int x = 5 , y = 10 , s = 40 ; findTemperature ( x , y , s ) ; } }