Weighted grade calculator in Java