APT: Simple Average AimToTen

Class

public class AimToTen { public int need(int[] marks) { // fill in code here } }

Problem Statement

You are given a int[] marks containing the grades you have received so far in a class. Each grade is between 0 and 10, inclusive. Assuming that you will receive a 10 on all future assignments, determine the minimum number of future assignments that are needed for you to receive a final grade of 10. You will receive a final grade of 10 if your average grade is 9.5 or higher.

Constraints

Examples

  1. {9, 10, 10, 9}
    
    Returns: 0
    
    
    Your average is already 9.5, so no future assignments are needed.

  2. 
    {8, 9}
    
    Returns: 4
    
    
    In this case you need 4 more assignments. With each completed assignment, your average could increase to 9, 9.25, 9.4 and 9.5, respectively.

  3. 
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
    
    Returns: 950
    
    
  4.     	
    
    {10, 10, 10, 10}
    
    Returns: 0