Accepts the grades for the 4 quarters and compute the final grade consid

Can you help me.. Accepts the grades for the 4 quarters and compute the final grade consider the requirement. The first 3 quarters must be multiplied by 20%, while the last quarter grade is multiplied by 40%.