--> //initializations 

--> w= 0.25 // (water content)
 w  = 

   0.25


--> Ys=20 //kg/m^3 (bulk unit weight)
 Ys  = 

   20.


--> Yw =10 //kg/^m3 (unit weight of water)
 Yw  = 

   10.


--> //calculations

--> G=Ys/(Yw+(Yw*w)-(w*Ys)) //(specific gravity)
 G  = 

   2.6666667


--> e=w*G //(void ratio)
 e  = 

   0.6666667


--> Yd=(G*Yw)/(1+e) //(dry unit weight)
 Yd  = 

   16.


--> //results

--> printf('specific gravity=%f',G) 
specific gravity=2.666667
--> printf('void ratio=%f',e)
void ratio=0.666667
--> printf('dry density=%f',Yd) //kN/m^3
dry density=16.000000
--> //for second case

--> s=0.80 // (degree of saturation)
 s  = 

   0.8


--> Y=((G+(s*e))*Yw)/(1+e) //(unit weight)
 Y  = 

   19.2


--> printf('bulk unit weight=%f',Y)//kN/m^3
bulk unit weight=19.200000