Began code to calculate values