Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using this Java code: public class Paper2 { static final int BONUS_POINTS = 5; s

ID: 3749290 • Letter: U

Question

Using this Java code:

public class Paper2

{

static final int BONUS_POINTS = 5;

static void addBonus(int[] array1, int[] shouldAdd)

{

   for (int i = 0; i < array1.length; i++)

   {

       if (shouldAdd[i] == 1)

       {

           array1[i] = array1[i] + BONUS_POINTS;

       }

   }

}

static double calculateStat1 (int[] a)

{

   int s = 0;

   for (int i = 0; i < a.length; i++)

   {

       s = s + a[i];

   }

   return s / (double)a.length;

}

static double calculateStat2(int[] a, double s1)

{

   double s = 0;

   for (int i = 0; i < a.length; i++)

   {

       s = s + (a[i] - s1) * (a[i] - s1);

   }

   return (Math.sqrt(s) / (a.length - 1));

}

public static void main(String[] args)

{

   int data[] = { 42, 97, 64, 53, 78, 96, 83 };

   int bonus[] = { 0, 1, 1, 0, 0, 1, 1 };

  

   addBonus(data, bonus);

  

   double stat1 = calculateStat1(data);

   System.out.println("The first static is " + stat1);

  

   double stat2 = calculateStat2(data, stat1);

   System.out.println("The second statistic is " + stat2);

  

   for (int i = 0; i < data.length; i++)

   {

       System.out.print(data[i] + " is ");

       double distance = (data[i] - stat1) / stat2;

       System.out.print(distance + " from " + stat1 + " which is a");

       if (distance < -1.5)

       {

           System.out.println("n F");

       }

       if ((distance >= -1.5) && (distance < -0.5))

       {

           System.out.println(" D");

       }

       if ((distance >= -0.5) && (distance < 0.5))

       {

           System.out.println(" C");

       }

       if ((distance >= 0.5) && (distance < 1.5))

       {

           System.out.println(" B");

       }

       if (distance >= 1.5)

       {

           System.out.println("n A");

       }

   }

}

}

Write the descriptions that could be used as the comments for each of the following:

a. BONUS_POINTS

b. calculateStat1()

c. calculateStat2()

d. Paper2 (for the comment at the top of the file)

Explanation / Answer

a. BONUS_POINTS
method to add bonus points to the score if the score is eligible
b. calculateStat1()
method to find the average of the scores
c. calculateStat2()
method to find the standard deviation of the scores
d. Paper2 (for the comment at the top of the file)
Program to find the average, standard deviation, bonus points and display the grade based on standard deviation for an exam

Let me know if you have any queries or clarifications.... :)
taken by the students