Conditional grade calculator